While Loop With Compound Condition
The following code segment models a safety check for an automated delivery truck. What is printed when the code is executed?
public class DeliveryCheck {
public static void main(String[] args) {
int leftDoor = 0;
int rightDoor = 0;
while(leftDoor < 3 && rightDoor < 5){
leftDoor++;
rightDoor += 2;
}
System.out.println(leftDoor + ", " + rightDoor);
}
}
A
3, 6
B
2, 6
C
3, 5
D
2, 4
Question Leaderboard
Not enough data yet to show leaderboard.
