Java For Loop Syntax Error
Which statement best explains why the following code segment fails to compile?
public class LoopError10 {
public static void main(String[] args) {
for (int i = 0; i < 5, i++) {
System.out.println(i);
}
}
}
A
The loop condition uses a wrong relational operator.
B
The loop variable ‘i’ is of an invalid data type.
C
The System.out.println statement inside the loop is missing parentheses.
D
The for loop header incorrectly uses a comma instead of a semicolon.
Question Leaderboard
| Rank | |||||
|---|---|---|---|---|---|
| #1 | pawarros000 | 3 | 3 | 1m 58s | 182 |
| #2 | suhanakochhar006 | 2 | 2 | 0m 31s | 169 |
| #3 | sgarv2513 | 1 | 1 | 0m 00s | 100 |
| #4 | hitrishabhatia | 1 | 2 | 0m 00s | 90 |
| #5 | y.seong2027 | 2 | 2 | 2m 06s | 74 |
| #6 | eeneskulca | 1 | 1 | 0m 29s | 71 |
| #7 | ravi.palepu | 1 | 1 | 0m 31s | 69 |
| #8 | tushartutoringservices | 1 | 1 | 0m 54s | 46 |
| #9 | psak12 | 1 | 2 | 1m 35s | -5 |
| #10 | midnightasdark | 1 | 2 | 1m 43s | -13 |
Items per page:
10
1 – 10 of 13
APFIVE