Limited access

Upgrade to access all content for this subject

Consider the following method.

public static int methodC(ArrayList<Integer> list)
{
    int num = 0;
    for(int i=0; i<list.size(); i++)
    {
           if (list.get(i)<0)
                return list.get(i)/list.size();
           num+=list.get(i);
    }
    return num/list.size();

}

Which of these lists would result in the method returning 0?

I.   {4, 6, -4, 9, 22}
II.  {}
III. {1, 2, 0, 1, 0}
IV.  {-6, -1, 0, 2, 3}
A

I and II only.

B

I and III only.

C

II and III only.

D

III and IV only.

E

I, II, III and IV.

Select an assignment template