?

AP® Computer Science A

Free Version

Upgrade subject to access all content

Moderate

Array Arithmetic Using an Array of Integers

APCSA-TAVX4M

Consider the following code segment.

int[] nums = {1, 2, 3};
int tot = 0;

for (int i=0; i<nums.length; i++)
{    
    for (int j=nums.length-1; j>0; j--)
    {
        tot += nums[i]*nums[j];
    }                
}
System.out.println(tot);

What will print to the console when the following segment of code is executed?

A

6

B

12

C

27

D

30

E

36