Which type of loop is recommended when the number of iterations is known beforehand?
A.
While loop
B.
Do-while loop
C.
For loop
D.
Infinite loop
What is the primary feature that distinguishes a do-while loop from a standard while loop?
A.
It guarantees that the code block inside the loop executes at least once before checking the condition.
B.
It can only handle integer control variables.
C.
It automatically terminates after 10 iterations.
D.
It does not require a termination condition.
According to the Java tutorial, how do you intentionally create an infinite loop using a while statement?
A.
while (0)
B.
while (false)
C.
while (null)
D.
while (true)
What is a common consequence of failing to update the control variable inside a while loop?
A.
A compilation syntax error.
B.
An infinite loop that may cause the program to hang, freeze, or crash.
C.
The program will automatically skip the loop.
D.
The control variable resets to zero.
Which practical programming task is a do-while loop most commonly used for, as demonstrated in the grading program example?
A.
Repeatedly asking a user for input (such as a score between 0 and 100) until a valid response is received.
B.
Printing patterns of asterisks horizontally.
C.
Declaring local constants like PI.
D.
Sorting numbers in descending order from 10 to 1.