Multiple choice

Which of the following statements is TRUE regarding the 'switch' statement?

  1. continue can be used but break cannot be used

  2. continue cannot be used but break can be used

  3. Both continue and break can be used

  4. Neither continue nor break can be used

  5. We cannot use switch statement in nested form

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

The break is used to break out of the case statements. Break is a keyword that breaks out of the code block, usually surrounded by braces, which it is in. In this case, break prevents the program from falling through and executing the code in all the other case statements.