Skip to main content

Data Types And Variables — Part 1 MCQs with Explanations

Practice high-yield Programming & Software Development MCQs on Data Types And Variables — Part 1 with worked academic solutions for FPSC, PPSC, NTS, NITB, PTS.

Questions
40
Difficulty Level
Exam-Level
Target Exams
FPSC, PPSC, NTS...
Estimated Time
48 mins
Exam-Level FPSC PPSC NTS NITB PTS
Content updated Oct 14, 2026
These practice questions are independent study material, not an official commission answer key. ExamHub.pk is reviewing older question sets; check important facts against the relevant commission's syllabus or another primary source. Report a correction.
40

Practice Questions

Interactive test mode with detailed academic worked solutions

Live Progress | 0/40 answered
✓ 0 correct ✗ 0 wrong 0% score
Question 1 of 40

What is the maximum value that can be stored in a byte variable in Java?

Question 2 of 40

Which data type is used to store a single character in Java?

Question 3 of 40

What is the default value of an int variable in Java if it's not explicitly initialized?

Question 4 of 40

Which of the following is not a valid identifier for a Java variable?

Question 5 of 40

Which data type is used to store floating-point numbers with single precision in Java?

Question 6 of 40

In Java, which data type is used to represent true or false values?

Question 7 of 40

What is the size of a long variable in Java?

Question 8 of 40

Which of the following is a valid way to declare a constant in Java?

Question 9 of 40

What is the range of values that can be stored in a short variable in Java?

Question 10 of 40

Which of the following is a primitive data type in Java?

Question 11 of 40

Which keyword is used to declare a variable that can hold a reference to an object of any class in Java?

Question 12 of 40

What is the default value of a boolean variable in Java if it's not explicitly initialized?

Question 13 of 40

Which of the following is the correct way to declare a hexadecimal value in Java?

Question 14 of 40

What is the minimum value that can be stored in a char variable in Java?

Question 15 of 40

In Java, which data type is used to store numbers with decimal points?

Question 16 of 40

Which of the following is not a primitive data type in Java?

Question 17 of 40

What is the default value of a double variable in Java if it's not explicitly initialized?

Question 18 of 40

What is the keyword used to declare a constant value in Java?

Question 19 of 40

Which of the following is not a valid way to declare an integer variable in Java?

Question 20 of 40

In Java, which data type is used to store numbers with decimal points and greater precision than float?

Question 21 of 40

What is the default value of a char variable in Java if it's not explicitly initialized?

Question 22 of 40

Which data type is used to represent integer values in Java?

Question 23 of 40

Which of the following is the correct way to declare a boolean variable named isJavaFun and initialize it to true in Java?

Question 24 of 40

What is the size of a float variable in Java?

Question 25 of 40

Which of the following is not a valid way to declare a long variable in Java?

Question 26 of 40

Which of the following is the correct way to declare a byte variable named myByte and initialize it to 5 in Java?

Question 27 of 40

What is the range of values that can be stored in a char variable in Java?

Question 28 of 40

Which data type is used to store numbers with decimal points and less precision than double?

Question 29 of 40

What is the default value of a boolean array element in Java if it's not explicitly initialized?

Question 30 of 40

Which of the following is not a valid way to declare a char variable in Java?

Question 31 of 40

Java is a ........... language.

Question 32 of 40

How many primitive data types are there in Java?

Question 33 of 40

In Java byte , short , int and long all of these are

Question 34 of 40

Size of int in Java is

Question 35 of 40

The smallest integer type is ......... and its size is ......... bits.

Question 36 of 40

Size of float and double in Java is

Question 37 of 40

Determine output: class A{ public static void main(String args[]){ int x; x = 10; if(x == 10){ int y = 20; System.out.print("x and y: "+ x + " " + y); y = x*2; } y = 100; System.out.print("x and y: " + x + " " + y); } }

Question 38 of 40

Automatic type conversion in Java takes place when

Question 39 of 40

Which of the following automatic type conversion will be possible?

Question 40 of 40

What is the output of the following program? class A{ public static void main(String args[]){ byte b; int i = 258; double d = 325.59; b = (byte) i; System.out.print(b); i = (int) d; System.out.print(i); b = (byte) d; System.out.print(b); } }

✓ Link copied to clipboard

💡 Examiner's Advisory for Programming & Software Development

In competitive commission exams (FPSC, PPSC, KPPSC, SPSC, CSS, PMS), questions are frequently phrased with distractor options designed to catch rote learners. Whenever you answer an MCQ, read the Detailed Academic Explanation and Conceptual Anchor to understand why the remaining options are incorrect.

More Modules in Programming & Software Development

View All →
📚

Study Guides

Topic summaries and syllabus breakdown

Explore Guides →
🎯

Complete Library

Search the practice question library

Browse Library →
📱

Mobile App

Offline mock tests and instant bookmarks

Get Mobile App →