?

AP® Computer Science A

Free Version

Upgrade subject to access all content

Moderate

Debugging Code: Print Adjusted Scores from Arrays

APCSA-ZG46KL

Consider the following method.

public static void printAdjustedScores(int[] scores)
{
    int i;
    for (i=0; i<scores.length; i++)
    {
        if(scores[i]>100)
            scores[i]=100;
        else
        if (scores[i]<70)
            scores[i]=70;
    }

    for(int j=i; j>=0; j--)
    {
        System.out.print(scores[j] + ",");
    }
}

What is the output when running the following code from the main method?

int[] scores = {87, 50, 90, 105};
printAdjustedScores(scores);
A

100, 90, 70, 87

B

105, 90, 50, 87

C

A NumberConversionException is thrown.

D

An ArithmeticException is thrown.

E

An ArrayIndexOutOfBoundsException is thrown.