Single Choice Easy

QThe statement to stop the execution of a construct

ID: #22236 switch case in Java 101 views
Question Info
#22236Q ID
EasyDifficulty
switch case in JavaTopic

Choose the Best Option

Click any option to instantly check if you're correct.

  • A System.exit(0)
  • B break
  • C stop
  • D end
Correct Answer

Explanation

To stop the execution of a construct, such as a loop or a switch statement, the correct statement is:

b) break

Explanation:

  • break: This statement is used to exit from a loop (like for, while, or do-while) or a switch statement. When break is encountered, the execution of the loop or switch construct is immediately terminated.

  • System.exit(0): This terminates the entire Java Virtual Machine (JVM), not just a single construct.

  • stop: This is not a valid Java statement for stopping execution.

  • end: This is not a valid Java statement for stopping execution.

Correct Answer:

b) break

Share This Question

Challenge a friend or share with your study group.