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

Consider the following code segment.

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

All of the following statements about the while loop are true EXCEPT:

A

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

B

The loop executes only while both conditions are satisfied.

C

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

D

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

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
#1y.seong202722 0m 28s 172
#2hitrishabhatia13 0m 00s 80
#3khanhnguyen.thor11 1m 34s 6
Items per page:
10
1 – 3 of 3
No comments yet. Be the first to comment!

AI Tutor

How can I help?

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