Limited access

Upgrade to access all content for this subject

Consider the following method.

/**
 * calculate total snowfall this winter
 * @param snowfall array of snowfall levels by month
 */
public static double calcSnowfall(double[] snowfall)
{
     double total;
     for (int i; i<snowfall.length; i++)
     {
         total+=snowfall[i];
     }
     return total;
}

Which of the following describe why this code will produce an error?

I.    It will not compile because total is not initialized
II.   It will not compile because i is not initialized
III.  The variable i will be incremented too far (past the ending index of the array)
A

I only.

B

II only.

C

I and II only.

D

II and III only.

E

I, II, and III.

Select an assignment template