Free Version
Difficult

# Objects as Parameters in Method Calls

APCSA-SGT4S1

Consider the following method.

public static ArrayList<Double> updatePercentages(ArrayList<Double> pcts)
{
ArrayList<Double> percentsNoDecimals = pcts;
for (int i=0; i<pcts.size(); i++)
{
pcts.set(i, pcts.get(i) * 100);
percentsNoDecimals.set(i, pcts.get(i)*100);
}
return percentNoDecimals;
}


What prints to the console after the following segment of code is executed?

ArrayList<Double> percentages = new ArrayList<Double>();

ArrayList<Double> newPercents = updatePercentages(percentages);
newPercents.set(0, 0.0);

System.out.println("percentages = " + percentages);
System.out.println("newPercents = " + newPercents);

A
percentages = [.09, .75, .38, 1.0]
newPercents = [0.0, 75.0, 38.0, 100.0]

B
percentages = [0.0, 7500.0, 3800.0, 10000.0]
newPercents = [0.0, 7500.0, 3800.0, 10000.0]

C
percentages = [9.0, 75.0, 38.0, 100.0]
newPercents = [0.0, 75.0, 38.0, 100.0]

D
percentages = [9.0, 75.0, 38.0, 100.0]
newPercents = [0.0, 7500.0, 3800.0, 10000.0]

E
percentages = [0.0, 75.0, 38.0, 100.0]
newPercents = [0.0, 75.0, 38.0, 100.0]