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