?

AP® Computer Science A

Free Version

Upgrade subject to access all content

Difficult

While Loop Arithmetic Operations

APCSA-EETBXJ

Consider the following code segment.

int x=0, y=20;

// missing while header
{
    y=y-2;
    x++;
}
System.out.println(y);

Which of the following could be used to replace // missing while header such that the code segment will print 10 to the console when executed?

A
while (y<=20 || x<5)
B
while (y<=20)
C
while (y>=20 || x<=5)
D
while (y>=20 && x<5)
E
while (y<=20 && x<5)