While Loop With Compound Condition
An automated delivery truck checks that both its left and right doors satisfy safety conditions before departure. What is the output of the code?
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
2, 6
B
3, 6
C
2, 4
D
3, 5
Question Leaderboard
Not enough data yet to show leaderboard.
APFIVE