Flow Control — Part 2 MCQs with Explanations
Practice high-yield Programming & Software Development MCQs on Flow Control — Part 2 with worked academic solutions for FPSC, PPSC, NTS, NITB, PTS.
Questions
14
Difficulty Level
Exam-Level
Target Exams
FPSC, PPSC, NTS...
Estimated Time
17 mins
Exam-Level FPSC PPSC NTS NITB PTS
Verified for Commission Syllabus • Oct 14, 2026
14
Verified Practice Questions
Interactive test mode with detailed academic worked solutions
Live Progress | 0/14 answered
✓ 0 correct
✗ 0 wrong
0% score
🎉 Set complete! All 14 questions answered.
Question 1 of 14
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Question 2 of 14
★ FPSC
★ PPSC
★ FPSC
★ PPSC
How many times will the following code print "Welcome to Examveda"? int count = 0; do { System.out.println("Welcome to Examveda"); count++; } while (count < 10);
Question 3 of 14
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Choose the correct statement in context of the following program code. public class Test{ public static void main(String[] args){ double sum = 0; for(double d = 0; d < 10;){ d += 0.1; sum += sum + d; } } }
Question 4 of 14
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following for loops will be an infinite loop?
Question 5 of 14
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the result of the following code? public class Test{ static public void main(String args[]){ //line 2 int i, j; for(i=0; i<3; i++){ for(j=1; j<4; j++){ i%=j; System.out.println(j); } } } }
Question 6 of 14
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What all gets printed when the following program is compiled and run. public class Test{ public static void main(String args[]){ int i, j=1; i = (j>1)?2:1; switch(i){ case 0: System.out.println(0); break; case 1: System.out.println(1); case 2: System.out.println(2); break; case 3: System.out.println(3); break; } } }
Question 7 of 14
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What all gets printed when the following program is compiled and run? public class Test{ public static void main(String args[]){ int i=0, j=2; do{ i=++i; j--; }while(j>0); System.out.println(i); } }
Question 8 of 14
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output? public class Test{ public static void main(String args[]){ int i = 1; do{ i--; }while(i > 2); System.out.println(i); } }
Question 9 of 14
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of these access specifier must be used for class so that it can be inherited by another subclass?
Question 10 of 14
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of these is used as a default for a member of a class if no access specifier is used for it?
Question 11 of 14
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Java code? class static_out { static int x; static int y; void add(int a, int b) { x = a + b; y = x + b; } } public class static_use { public static void main(String args[]) { static_out obj1 = new static_out(); static_out obj2 = new static_out(); int a = 2; obj1.add(a, a + 1); obj2.add(5, a); System.out.println(obj1.x + " " + obj2.y); } }
Question 12 of 14
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Java code? class access { public int x; private int y; void cal(int a, int b) { x = a + 1; y = b; } } public class access_specifier { public static void main(String args[]) { access obj = new access(); obj.cal(2, 3); System.out.println(obj.x + " " + obj.y); } }
Question 13 of 14
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of these is used to access a member of class before object of that class is created?
Question 14 of 14
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Java code? class access { public int x; private int y; void cal(int a, int b) { x = a + 1; y = b; } void print() { System.out.println(" " + y); } } public class access_specifier { public static void main(String args[]) { access obj = new access(); obj.cal(2, 3); System.out.println(obj.x); obj.print(); } }
✓ Link copied to clipboard
Continue Your Practice
Next Practice Set → Advance Html — Part 1
Master the next curriculum module with 40 exam-standard MCQs.
💡 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.