Skip to main content

Flow Control — Part 1 MCQs with Explanations

Practice high-yield Programming & Software Development MCQs on Flow Control — 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
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{ public static void main(String args[]){ int i, j; for(i=1, j=0;i<10;i++) j += i; System.out.println(i); } }

Question 2 of 40
★ FPSC ★ PPSC

What will be the output? public class Test{ public static void main(String[] args){ int x=10, y=0; if(x && y){ System.out.print("TRUE"); } else{ System.out.print("FALSE"); } } }

Question 3 of 40
★ FPSC ★ PPSC

What will be the value of y after execution of switch statement? public class Test{ public static void main(String[] args){ int x = 3, y = 4; switch(x + 3){ case 6: y = 0; case 7: y = 1; default: y += 1; } } }

Question 4 of 40
★ FPSC ★ PPSC

What will be the result of compiling and running the following code: public class Test{ public static void main(String... args) throws Exception{ Integer i = 34; int l = 34; if(i.equals(l)){ System.out.println("true"); }else{ System.out.println("false"); } } }

Question 5 of 40
★ FPSC ★ PPSC

public class Test{ public static void main(String [] args){ int x = 0; // insert code here do{ } while(x++ < y); System.out.println(x); } } Which option, inserted at line 4, produces the output 12?

Question 6 of 40
★ FPSC ★ PPSC

What will be the result? int i = 10; while(i++ <= 10){ i++; } System.out.print(i);

Question 7 of 40
★ FPSC ★ PPSC

What is the purpose of the "if" statement in Java?

Question 8 of 40
★ FPSC ★ PPSC

Which of the following is not a valid comparison operator in Java?

Question 9 of 40
★ FPSC ★ PPSC

What is the output of the following code snippet? int x = 5; if (x > 3) { System.out.println("Hello"); }

Question 10 of 40
★ FPSC ★ PPSC

In Java, which statement is used to exit a loop prematurely?

Question 11 of 40
★ FPSC ★ PPSC

What is the purpose of the "switch" statement in Java?

Question 12 of 40
★ FPSC ★ PPSC

What is the default case in a "switch" statement used for?

Question 13 of 40
★ FPSC ★ PPSC

In Java, which loop is suitable when you want to execute a block of code a specific number of times?

Question 14 of 40
★ FPSC ★ PPSC

What is the result of the following code snippet? int i = 1; while (i <= 5) { System.out.print(i + " "); i++; }

Question 15 of 40
★ FPSC ★ PPSC

Which of the following is true about the "do-while" loop in Java?

Question 16 of 40
★ FPSC ★ PPSC

In Java, what does the "continue" statement do?

Question 17 of 40
★ FPSC ★ PPSC

What is the output of the following code snippet? int j = 0; while (j < 5) { System.out.print(j + " "); j += 2; }

Question 18 of 40
★ FPSC ★ PPSC

In Java, what does the "break" statement do in a loop?

Question 19 of 40
★ FPSC ★ PPSC

What is the purpose of the "for-each" loop in Java?

Question 20 of 40
★ FPSC ★ PPSC

In Java, what does the "default" keyword refer to in a "switch" statement?

Question 21 of 40
★ FPSC ★ PPSC

What is the result of the following code snippet? int k = 10; do { System.out.print(k + " "); k -= 2; } while (k > 0);

Question 22 of 40
★ FPSC ★ PPSC

In Java, which loop is used when you want to execute a block of code as long as a condition is true?

Question 23 of 40
★ FPSC ★ PPSC

What is the output of the following code snippet? for (int m = 0; m < 5; m++) { if (m == 2) { continue; } System.out.print(m + " "); }

Question 24 of 40
★ FPSC ★ PPSC

In Java, what does the "switch" statement evaluate to determine which case to execute?

Question 25 of 40
★ FPSC ★ PPSC

What is the purpose of the "if-else" statement in Java?

Question 26 of 40
★ FPSC ★ PPSC

Which of the following is a valid way to create an infinite loop in Java?

Question 27 of 40
★ FPSC ★ PPSC

In Java, what is the purpose of the "if-else if-else" statement?

Question 28 of 40
★ FPSC ★ PPSC

What is the output of the following code snippet? int n = 5; for (int i = 0; i < n; i++) { System.out.print(i + " "); }

Question 29 of 40
★ FPSC ★ PPSC

In Java, which loop is used when you want to execute a block of code at least once?

Question 30 of 40
★ FPSC ★ PPSC

What does the "else" statement in an "if-else" statement block indicate?

Question 31 of 40
★ FPSC ★ PPSC

In Java, what does the "continue" statement do in a loop?

Question 32 of 40
★ FPSC ★ PPSC

What is the purpose of the "break" statement in a "switch" statement?

Question 33 of 40
★ FPSC ★ PPSC

In Java, what does the "default" case in a "switch" statement do?

Question 34 of 40
★ FPSC ★ PPSC

What is the output of the following code snippet? int p = 3; switch (p) { case 1: System.out.print("One"); case 2: System.out.print("Two"); default: System.out.print("Default"); }

Question 35 of 40
★ FPSC ★ PPSC

In Java, what is the purpose of the "for-each" loop?

Question 36 of 40
★ FPSC ★ PPSC

Which keyword is used to exit a loop in Java?

Question 37 of 40
★ FPSC ★ PPSC

Determine output: public class Test{ public static void main(String args[]){ int i; for(i = 1; i < 6; i++){ if(i > 3) continue ; } System.out.println(i); } }

Question 38 of 40
★ FPSC ★ PPSC

In java, ............ can only test for equality, where as .......... can evaluate any type of the Boolean expression.

Question 39 of 40
★ FPSC ★ PPSC

What will be the output of the following program? public class Test{ public static void main(String args[]){ int i = 0, j = 5 ; for( ; (i < 3) && (j++ < 10) ; i++ ){ System.out.print(" " + i + " " + j ); } System.out.print(" " + i + " " + j ); } }

Question 40 of 40
★ FPSC ★ PPSC

Consider the following program written in Java. class Test{ public static void main(String args[]){ int x=7; if(x==2); // Note the semicolon System.out.println("NumberSeven"); System.out.println("NotSeven"); } } What would the output of the program be?

✓ 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 →