Java continue Statement - Quiz

Total: 5 questions

1. 

What does the continue statement do in Java?

It ends the current iteration of a loop early: the remaining statements in the loop body are skipped, and control moves on to the next iteration. Unlike break, the loop itself keeps running.

2. 

Where does control go after continue in for, while, and do-while loops?

In a for loop, control jumps first to the update expression (such as i++) and then to the condition check. In while and do-while loops, control goes straight to the conditional expression that governs the loop.

3. 

Can the continue statement be used outside a loop? What happens if you try?

No. continue is allowed only inside a loop. If you write it anywhere else, the code will not compile and the compiler reports the error continue outside of loop.

4. 

What is a labeled continue, and when do you need it?

A plain continue only affects the nearest enclosing loop. Inside nested loops, continue label; ends the current iteration of the outer loop marked with that label instead of the inner one. The label (any valid Java identifier followed by a colon) must be placed immediately before the loop it refers to, for example outer: for (...) { ... continue outer; ... }.

5. 

How does continue differ from break?

Both are jump statements, but continue skips only the rest of the current iteration and lets the loop carry on, while break terminates the loop completely — execution resumes at the first statement after the loop.

Page 1 of 1