MCQ
Single Best Answer
Moderate
QWhat will be the output of the following Java code?
for (int i = 0; i < 3; i++) {
System.out.println(i);
}
ID: #23074
For Loop in Programming Language
70 views
Question Info
#23074Q ID
ModerateDifficulty
For Loop in Programming LanguageTopic
Your Answer
Choose the Best Option
Click any option to instantly check if you're correct.
Correct Answer: Option A
Explanation
The loop starts with i = 0 and prints the value of i in each iteration. The loop increments i by 1 after each iteration, and it runs as long as i < 3. Therefore, it prints 0, 1, and 2. Once i becomes 3, the loop condition i < 3 becomes false, and the loop terminates, so 3 is not printed. The correct sequence of outputs is 0 1 2.
Continue Practice
Share
Share This Question
Challenge a friend or share with your study group.
More from This Topic