Break Statement In A Nested Loop
All of the following statements about the nested loops above are true except:
public class NestedBreak {
public static void main(String[] args) {
for(int i = 0; i < 3; i++) {
for(int j = 0; j < 3; j++) {
if(i == j) {
break;
}
System.out.print(i + "," + j + " ");
}
}
}
}
A
The code only prints pairs (i, j) when i is not equal to j until the break condition is met.
B
The break statement inside the inner loop causes premature termination when i equals j.
C
The inner loop executes fully for every iteration of the outer loop without interruption.
D
The behavior of the nested loops is influenced by both i and j, especially due to the break condition.
Question Leaderboard
Not enough data yet to show leaderboard.
APFIVE