Loop in Java MCQs Exercise II
Ques 1
Loop
Which statement is used to exit a loop prematurely?
A break
B continue
C return
D exit
Ques 2
Loop
What is the output of the following Java code snippet?
int i = 5;
do {
System.out.print(i + " ");
i--;
} while (i > 0);
A 5 4
B 5 4 3
C 5 4 3 2
D 5 4 3 2 1
Ques 3
Loop
What is the output of the following Java code snippet?
int i = 0;
while (i < 5) {
System.out.print(i + " ");
i += 2;
}
A 0 1 2 3 4
B 0 2 4
C 0 2 4 6 8
D 0 1 2 3