Skip to main content

Data Types And Variables — Part 2 MCQs with Explanations

Practice high-yield Programming & Software Development MCQs on Data Types And Variables — Part 2 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
Verified for Commission Syllabus • Oct 14, 2026
40

Verified 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
★ FPSC ★ PPSC

Determine output: public class Test { static void test(float x){ System.out.print("float"); } static void test(double x){ System.out.print("double"); } public static void main(String[] args){ test(99.9); } }

Question 2 of 40
★ FPSC ★ PPSC

What is the output of the following program? public class Test{ static int x = 10 ; public static void main(String[] a){ Test test = new Test( ) ; Test test1 = new Test( ) ; test.x += 1 ; System.out.println( test.x + test1.x ) ; } }

Question 3 of 40
★ FPSC ★ PPSC

What will be output of the following program code? public class Test{ public static void main(String[] a){ short x = 10; x = x*5; System.out.print(x); } }

Question 4 of 40
★ FPSC ★ PPSC

Determine output: public class Test{ int i = 34; public static void main(String args[]){ Test t1 = new Test(); Test t2 = new Test(); t1.i = 65; System.out.print(t1.i); System.out.print(t2.i); } }

Question 5 of 40
★ FPSC ★ PPSC

The following program: public class Test{ static boolean isOK; public static void main(String args[]){ System.out.print(isOK); } }

Question 6 of 40
★ FPSC ★ PPSC

What will the output of the following program? public class Test{ public static void main(String args[]){ float f = (1 / 4) * 10; int i = Math.round(f); System.out.println(i); } }

Question 7 of 40
★ FPSC ★ PPSC

What is the output for the below code? class A{ int k; boolean istrue; static int p; public void printValue(){ System.out.print(k); System.out.print(istrue); System.out.print(p); } } public class Test{ public static void main(String argv[]){ A a = new A(); a.printValue(); } }

Question 8 of 40
★ FPSC ★ PPSC

What is the output for the below code? public class Test{ int _$; int $7; int do; public static void main(String argv[]){ Test test = new Test(); test.$7=7; test.do=9; System.out.println(test.$7); System.out.println(test.do); System.out.println(test._$); } }

Question 9 of 40
★ FPSC ★ PPSC

What is the output for the below code? public class Test{ public static void main(String[] args){ int i = 010; int j = 07; System.out.println(i); System.out.println(j); } }

Question 10 of 40
★ FPSC ★ PPSC

What is the output for the below code? public class Test{ public static void main(String[] args){ byte b = 6; b+=8; System.out.println(b); b = b+7; System.out.println(b); } }

Question 11 of 40
★ FPSC ★ PPSC

What will be the output for the below code? public class Test{ public static void main(String[] args){ byte i = 128; System.out.println(i); } }

Question 12 of 40
★ FPSC ★ PPSC

What will be the output for the below code? public class Test{ int i=8; int j=9; public static void main(String[] args){ add(); } public static void add(){ int k = i+j; System.out.println(k); } }

Question 13 of 40
★ FPSC ★ PPSC

What will be output of following program? public class Test{ public static void main(String[] args){ byte b=127; b++; b++; System.out.println(b); } }

Question 14 of 40
★ FPSC ★ PPSC

Determine output: public class Test{ int a = 10; public void method(int a){ a += 1; System.out.println(++a); } public static void main(String args[]){ Test t = new Test(); t.method(3); } }

Question 15 of 40
★ FPSC ★ PPSC

What will be the output of the following Java code? class increment { public static void main(String args[]) { int g = 3; System.out.print(++g * 8); } }

Question 16 of 40
★ FPSC ★ PPSC

What will be the output of the following Java program? class variable_scope { public static void main(String args[]) { int x; x = 5; { int y = 6; System.out.print(x + " " + y); } System.out.println(x + " " + y); } }

Question 17 of 40
★ FPSC ★ PPSC

The following fraction of code double STATIC = 2.5 ; System.out.println( STATIC );

Question 18 of 40
★ FPSC ★ PPSC

What would be the output of the following fraction of code? int Integer = 34 ; char String = 'S' ; System.out.print( Integer ) ; System.out.print( String ) ;

Question 19 of 40
★ FPSC ★ PPSC

In Java, the word true is ................

Question 20 of 40
★ FPSC ★ PPSC

Which class does all the Enums extend?

Question 21 of 40
★ FPSC ★ PPSC

Which of the following is the advantage of BigDecimal over double?

Question 22 of 40
★ FPSC ★ PPSC

What will be the output of the following Java code snippet? double a = 0.02; double b = 0.03; double c = b - a; System.out.println(c); BigDecimal _a = new BigDecimal("0.02"); BigDecimal _b = new BigDecimal("0.03"); BigDecimal _c = b.subtract(_a); System.out.println(_c);

Question 23 of 40
★ FPSC ★ PPSC

What is the range of short data type in Java?

Question 24 of 40
★ FPSC ★ PPSC

Is SimpleDateFormat thread safe?

Question 25 of 40
★ FPSC ★ PPSC

Which of these can not be used for a variable name in Java?

Question 26 of 40
★ FPSC ★ PPSC

Are enums are type-safe?

Question 27 of 40
★ FPSC ★ PPSC

Which of the below data type doesn't support overloaded methods for +,-,* and /?

Question 28 of 40
★ FPSC ★ PPSC

How to convert a String to a Date object?

Question 29 of 40
★ FPSC ★ PPSC

What is BigDecimal.ONE?

Question 30 of 40
★ FPSC ★ PPSC

What will be the error in the following Java code? byte b = 50; b = b * 50;

Question 31 of 40
★ FPSC ★ PPSC

Which of these values can a boolean variable contain?

Question 32 of 40
★ FPSC ★ PPSC

If an expression contains double, int, float, long, then the whole expression will be promoted into which of these data types?

Question 33 of 40
★ FPSC ★ PPSC

What will be the output of the following Java program? class dynamic_initialization { public static void main(String args[]) { double a, b; a = 3.0; b = 4.0; double c = Math.sqrt(a * a + b * b); System.out.println(c); } }

Question 34 of 40
★ FPSC ★ PPSC

Which of these can be returned by the operator &?

Question 35 of 40
★ FPSC ★ PPSC

Which data type value is returned by all transcendental math functions?

Question 36 of 40
★ FPSC ★ PPSC

What is the prototype of the default constructor of this Java class? public class prototype { }

Question 37 of 40
★ FPSC ★ PPSC

What will be the output of the following Java program, if we run as "java main_arguments 1 2 3"? class main_arguments { public static void main(String [] args) { String [][] argument = new String[2][2]; int x; argument[0] = args; x = argument[0].length; for (int y = 0; y < x; y++) System.out.print(" " + argument[0][y]); } }

Question 38 of 40
★ FPSC ★ PPSC

Which of these literals can be contained in float data type variable?

Question 39 of 40
★ FPSC ★ PPSC

What will be the output of the following Java code? class A { final public int calculate(int a, int b) { return 1; } } class B extends A { public int calculate(int a, int b) { return 2; } } public class output { public static void main(String args[]) { B object = new B(); System.out.print("b is " + b.calculate(0, 1)); } }

Question 40 of 40
★ FPSC ★ PPSC

What will be the output of the following Java code snippet? enum Levels { private TOP, public MEDIUM, protected BOTTOM; }

✓ Link copied to clipboard
Continue Your Practice

Advance Html — Part 1

Master the next curriculum module with 40 exam-standard MCQs.

Next Practice Set →

💡 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 through 78,000+ verified MCQs

Browse Library →
📱

Mobile App

Offline mock tests and instant bookmarks

Get Mobile App →