| preferred AP College board partner for AP classes
AP Computer Science A/Unit 4: Iteration
Start Practice TestPractice Test
About Exam
easy Solved by 18 students
Java For Loop Syntax Error
< Prev
Next >

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.

Hint
Did You Know?
Explain Why
Explain All Answers
Check Answer
Show Correct Answer
Report Question

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Time
Score
#1pawarros00033 1m 58s 182
#2suhanakochhar00622 0m 31s 169
#3sgarv251311 0m 00s 100
#4hitrishabhatia12 0m 00s 90
#5y.seong202722 2m 06s 74
#6eeneskulca11 0m 29s 71
#7ravi.palepu11 0m 31s 69
#8tushartutoringservices11 0m 54s 46
#9psak1212 1m 35s -5
#10midnightasdark12 1m 43s -13
Items per page:
10
1 – 10 of 13
No comments yet. Be the first to comment!

AI Tutor

How can I help?

APFIVE © 2020.
Email: apfive@apfive.org|Privacy Policy