In Java, the while loop is a fundamental control flow statement that executes a block of code repeatedly as long as a given condition evaluates to true. It is a pre-test loop, meaning the condition is checked before each iteration, which allows it to run zero or more times depending on the logic.
Time limit: 0
Quiz Summary
0 of 15 Questions completed
Questions:
Information
You have already completed the quiz before. Hence you can not start it again.
What is the primary condition for entering a while loop?
Correct
Incorrect
Question 2 of 15
2. Question
What is the output of this code?
int i = 1; while (i <= 3) { System.out.print(i); i++; }
Correct
Incorrect
Question 3 of 15
3. Question
What is the minimum number of times a `while` loop can execute?
Correct
Incorrect
Question 4 of 15
4. Question
Which of the following can lead to an infinite `while` loop?
Correct
Incorrect
Question 5 of 15
5. Question
What is the output of:
int x = 5; while (x > 0) { System.out.print(x + ” “); x–; }
Correct
Incorrect
Question 6 of 15
6. Question
Which of the following is a correct `while` loop syntax?
Correct
Incorrect
Question 7 of 15
7. Question
What is printed?
int i = 0; while (i < 2) { i++; System.out.println(i); }
Correct
Incorrect
Question 8 of 15
8. Question
Which keyword is used to skip the current iteration of a `while` loop?
Correct
Incorrect
Question 9 of 15
9. Question
What happens if the loop condition is never false?
Correct
Incorrect
Question 10 of 15
10. Question
Which of the following is **NOT** true about `while` loop?
Correct
Incorrect
Question 11 of 15
11. Question
What is the output?
What is the output? int i = 3; while (i >= 0) { System.out.print(i + ” “); i–; }
Correct
Incorrect
Question 12 of 15
12. Question
Can a `while` loop contain another loop inside it?
Correct
Incorrect
Question 13 of 15
13. Question
What is the correct way to declare an infinite `while` loop?
Correct
Incorrect
Question 14 of 15
14. Question
Which of the following can be used to terminate a `while` loop early?
Correct
Incorrect
Question 15 of 15
15. Question
What is the output of:
int i = 1; while (i <= 3) System.out.print(i++);
Correct
Incorrect
Summary
These MCQs test your understanding of Java’s `while` loop syntax, flow control, conditions, and behaviours. Perfect for interviews, Java assessments, and competitive exams.
At QuizOrbit, our team specializes in fun, informative quizzes across topics like general knowledge, technology, and entertainment. Boost your knowledge with our expert-designed quizzes.