MCQ
Single Best Answer
Moderate
QWhich of the following statements will exit a while loop in Java?
ID: #23085
While Loop in Programming Language
89 views
Question Info
#23085Q ID
ModerateDifficulty
While Loop in Programming LanguageTopic
Your Answer
Choose the Best Option
Click any option to instantly check if you're correct.
Correct Answer: Option B
Explanation
In Java, the break statement is used to exit a loop prematurely, regardless of the loop's condition. When the break statement is encountered in a while loop, the loop stops executing, and control is passed to the first statement after the loop. The continue statement skips the current iteration but does not terminate the loop, while return exits the method in which the loop is contained, which can also stop the loop if the method ends. pass is a keyword used in Python but does not apply to Java.
Continue Practice
Share
Share This Question
Challenge a friend or share with your study group.
More from This Topic