?

AP® Computer Science A

Free Version

Upgrade subject to access all content

Difficult

Wacky Looping Through An Array of Integers

APCSA-XLYOEP

The following code was produced by a wacky programmer. What is printed?

int age[] = {20, 10, 80, 50};
for (int i=age.length-1; i>=0; i--)
{
    for (int j=0; j<age.length; j++)
    {
        int temp = age [i];
        age[i]=age[j]-2;
        age[j]=temp+2;
    }
}
for (int i=0; 1<age.length; i++)
    System.out.print(age[i] +  " ");
A

80 50 20 10

B

20 10 80 50

C

76 58 20 14

D

22 12 82 52

E

72 48 12 4