Java OCA OCP Practice Question 1780

Question

Which statements are valid when occurring on their own?.

Select the three correct answers.

  • (a) while () break;
  • (b) do { break; } while (true);
  • (c) if (true) { break; }
  • (d) switch (1) { default: break; }
  • (e) for (;true;) break;


(b), (d), and (e)

Note

The loop condition in a while statement is not optional.

It is not possible to break out of the if statement in (c).

If the if statement had been placed within a labeled block, a switch statement, or a loop, the usage of break would be valid.




PreviousNext

Related