Question discussion

What will happen if we DO NOT use the break statement in a switch case?

359435Medium DSSSB TGT Computer Science 0 replies 0 views
0
What will happen if we DO NOT use the break statement in a switch case?
  • AThe program will throw a compilation error.
  • BThe control will continue executing the following cases until the end of the switch block is encountered.
  • CThe control will break out of the switch automatically after the first matching case.
  • DThe program will throw a runtime error.
Correct answer: B

Explanation

Without a break, the control falls through and executes the following cases until the end of the switch.

Discussion 0

Nobody has replied yet. Start the discussion!