Que 1.)
Which loop executes at least once, even if the condition is false?
-
for loop
-
while loop
-
do-while loop
-
foreach loop
option_c
The do-while loop executes at least once before checking the condition.
Que 2.)
What is the output of `for(int i=0; i<5; i++) { System.out.print(i); }`?
-
12345
-
01234
-
012345
-
54321
option_b
The loop starts from 0 and runs until i < 5, printing 01234.
Que 3.)
Which keyword is used to exit a loop prematurely in Java?
-
break
-
continue
-
exit
-
return
option_a
The break statement exits a loop prematurely when encountered.