Step 1: Understanding loops in Java.
Loops are used in programming to execute a block of code repeatedly until a certain condition becomes false. Java provides several looping constructs such as
for,
while, and
do...while.
Loops can be categorized as
entry-controlled loops or
exit-controlled loops.
Step 2: Entry-controlled vs exit-controlled loops.
In an
entry-controlled loop, the condition is checked before executing the loop body. Examples include the
for loop and
while loop.
In an
exit-controlled loop, the loop body executes first and the condition is checked afterward. This ensures that the loop executes at least once regardless of the condition.
Step 3: Understanding the do...while loop.
The
do...while loop is the only exit-controlled loop in Java. Its structure is:
do {
statements;
} while(condition);
In this loop, the statements inside the loop are executed first and then the condition is evaluated.
Step 4: Evaluation of options.
(A) for: Incorrect. It is an entry-controlled loop.
(B) while: Incorrect. It is also an entry-controlled loop.
(C) do...while: Correct. This is an exit-controlled loop.
(D) until: Incorrect. Java does not have an
until loop.
Step 5: Conclusion.
Therefore, the loop that is classified as an
exit-controlled loop in Java is the
do...while loop.
Final Answer: do...while