?

AP® Computer Science A

Free Version

Upgrade subject to access all content

Moderate

ArrayList get and set Methods Used to Change Elements

APCSA-SZTYEY

Consider the following method:

public static ArrayList<Integer> setList(ArrayList<Integer> nums)
{
   ArrayList<Integer> outputList = new ArrayList<Integer>();
   for (int i=0; i<nums.size(); i++)   
   {
       outputList.add(nums.get(i));
       if (outputList.get(i)%10==0 && i>0) 
           outputList.set(i-1, nums.get(i-1)*2);
   }
   return outputList;
}

What is the output after running the following section of code?

ArrayList<Integer> numsList = new ArrayList<Integer>();
numsList.add(10);
numsList.add(30);
numsList.add(44);
numsList.add(26);
numsList.add(60);
System.out.println(setList(numsList));
A
[20, 60, 44, 26, 120]
B
[10, 30, 44, 26, 60]
C
[20, 30, 44, 52, 60]
D
[10, 60, 88, 52, 60]
E

No output is displayed. An error is thrown.