?

AP® Computer Science A

Free Version

Upgrade subject to access all content

Moderate

ArrayIndexOutOfBoundsException on Array of Ints

APCSA-FPLCWZ

Which of the following fragments of code will result in an ArrayIndexOutOfBoundsException?
I.

int[] abc = new int[5];
for (int i=0; i<5; i++)
{
    abc[i-1] = i;
}

II.

int[] abc = new int[5];
for (int i=0; i<5; i++)
{
    abc[i] = i;
}

III.

int[] abc = new int[5];
for (int i=1; i<=5; i++)
{
    abc[i] = i;
}
A

I only.

B

I and II only.

C

I and III only.

D

II and III only.

E

I, II, and III.