Ques 1 Loop
Which loop in Java allows code to be executed repeatedly based on a condition?
a) for loop
b) while loop
c) do-while loop
d) All of the above
Ques 2 Loop
Which loop is guaranteed to execute the loop body at least once?
a) for loop
b) while loop
c) do-while loop
d) None of the above
Ques 3 Loop
What does the continue statement do in a loop?
a) Skips the remaining code in the loop and proceeds to the next iteration
b) Exits the loop and continues with the next statement after the loop
c) Restarts the loop from the beginning
d) None of the above
Ques 4 Loop
What is an infinite loop?
a) A loop that runs forever
b) A loop that does not run at all
c) A loop that executes only once
d) A loop that does not have a loop condition
Ques 5 Loop
What is the output of the following code snippet?
for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { if (j == 1) continue; System.out.print(i + " " + j + " "); } }
Ques 6 Loop
What is the output of the following Java code snippet?
int i = 0; while (i < 3) { int j = 0; while (j < 2) { if (i == 1 && j == 1) break; System.out.print(i + " " + j + " "); j++; } i++; }