What keyword is used to end the current loop iteration and proceed execution with the next iteration of that loop?

What keyword is used to end the current loop iteration and proceed execution with the next iteration of that loop?

A. break

B. continue

C. end

D. skip

Answer:

B. continue

Explanation:

Option A is incorrect because the break statement causes execution to proceed after the loop body. Options C and D are incorrect because these are not keywords in Java.

The continue keyword is used to end the loop iteration immediately and resume execution at the next iteration. Therefore, Option B is correct. 

Here's an example in Java:
for (int i = 0; i < 10; i++) {
    if (i % 2 == 0) {
        continue;
    }
    System.out.println(i);
}
In this example, the loop will print the odd numbers between 0 and 10. If the number is even, the "continue" statement is executed and the loop will immediately jump to the next iteration, skipping any statements below "continue" in the loop body for that iteration.

Comments