MCQ Single Best Answer Moderate

QHow can a for loop be prematurely terminated in Java?

ID: #23080 For Loop in Programming Language 95 views
Question Info
#23080Q ID
ModerateDifficulty
For Loop in Programming LanguageTopic

Choose the Best Option

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

  • A Using exit()
  • B Using return
  • C Using break
  • D Using continue
Correct Answer: Option C

Explanation

In Java, the break statement is used to prematurely terminate a loop. When a break statement is encountered inside a loop, the loop stops executing, and control is passed to the first statement following the loop. The return statement is used to exit a method, while continue skips the current iteration but does not terminate the loop. exit() is used to terminate the program, not a loop.

Share This Question

Challenge a friend or share with your study group.