Which statement immediately exits a switch statement, skipping all remaining case or default branches?

Which statement immediately exits a switch statement, skipping all remaining case or default branches?

A. exit

B. break

C. goto

D. continue

Answer:

B. break

Explanation:

The break statement exits a switch statement, skipping all remaining branches, making Option B the correct answer. 

In Option A, exit is not a statement in Java. In Option C, goto is a reserved word but unused in Java. Finally, in Option D, continue is a statement but only used for loops.

Comments