Limited access

Upgrade to access all content for this subject

Consider the following code.

public static boolean areArraysEqual(int[] array1, int[] array2)
{
    for (int i=0; i<array1.length; i++)
    {
        if (array1[i] != array2[i])
            return false; 
    }
    return true;
 }

What will the method return when it is passed the following combination of arrays?

I.

int[] array1 = {2, 4, 6, 8, 10};
int[] array2 = {2, 4, 6, 8, 10, 12, 14, 16};

II.

int[] array1 = {2, 4, 6, 8, 10};
int[] array2 = {2, 4, 6, 8, 10};

III.

int[] array1 = {2, 4, 6, 8, 10, 12, 14, 16};
int[] array2 = {2, 4, 6, 8, 10};

IV.

int[] array1 = {2, 4, 6, 8, 10};
int[] array2 = {2, 3, 7, 8, 10};
A
I.  true       II.  true         III.  throws error   IV.  false
B
I.  false      II.  true         III.  false          IV.  false
C
I.  true       II.  true         III.  false          IV.  false
D
I.  false      II.  true         III.  throws error   IV.  false
E
I. throws error  II.  true       III.  throws error   IV.  false
Select an assignment template