Limited access

Upgrade to access all content for this subject

Consider the following code.

int[] x = {8, 3, 5, 1, 7, 4};
int[] y = {2, 3, 9, 2, 7, 1};
int[] z = {6, 8, 1, 2, 5, 4};

for (int i=0; i<x.length; i++)
{
    if (x[i]<y[i])
    {
        int temp = x[i];
        x[i] = y[i];
        y[i] = temp;
    }
    else
    if (z[i]<x[i])
    {
        int temp =x[i];
        x[i] = z[i];
        z[i] = temp;
    }
    else
    if (y[i]<z[i])
    {
        int temp = y[i];
        y[i] = z[i];
        z[i] = temp;
    }
}

What are the elements in x, y, and z after the following code is executed?

A
x = {8, 3, 1, 2, 5, 4}  
y = {6, 8, 9, 2, 7, 4}  
z = {2, 3, 5, 1, 7, 1}
B
x = {6, 3, 9, 2, 7, 1}  
y = {2, 8, 5, 1, 5, 4}  
z = {8, 3, 1, 2, 7, 4}
C
x = {2, 3, 1, 1, 5, 1}  
y = {6, 8, 5, 2, 7, 4}  
z = {8, 3, 9, 2, 7, 4}
D
x = {6, 3, 9, 2, 5, 4}  
y = {2, 8, 5, 1, 7, 4}  
z = {8, 3, 1, 2, 7, 1}
E
x = {8, 3, 9, 2, 5, 4}  
y = {2, 3, 1, 2, 7, 1}  
z = {6, 8, 5, 1, 7, 4}
Select an assignment template