Java OCA OCP Practice Question 405

Question

Which of these statements are valid when occurring by themselves?

Select 3 options

  • A. while ( ) break ;
  • B. do { break ; } while (true) ;
  • C. if (true) { break ; } (When not inside a switch block or a loop)
  • D. switch (1) { default : break; }
  • E. for ( ; true ; ) break ;


Correct Options are  : B D E

Note

A. is wrong. The condition expression in a while header is required.

C. is wrong. Cannot have break or continue in an 'if' or 'else' block.

D. is correct. You can use a constant in switch (...);

It is not possible to break out of an if statement.




PreviousNext

Related