| preferred AP College board partner for AP classes
AP Computer Science A/Unit 4: Iteration
Start Practice Test
Share
medium Solved by 2 students
Compound Condition In A While Loop
< Prev
Next >

All of the following statements about the while loop above are true except:

public class ConditionLoop {
    public static void main(String[] args) {
        int a = 0;
        while(a < 5 && a != 3) {
            System.out.println(a);
            a++;
        }
    }
}
A

The loop executes only while both conditions are satisfied.

B

The loop stops when a equals 3 because the second condition (a != 3) becomes false.

C

The loop prints numbers from 0 to 4, ignoring the fact that a is compared to 3 in the condition.

D

The && operator requires both conditions (a < 5 and a != 3) to be true for the loop to execute.

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

Question Leaderboard

Not enough data yet to show leaderboard.

APFIVE © 2020.
Email: [email protected]|Privacy Policy