Limited access

Upgrade to access all content for this subject

Consider the following code segment.

ArrayList<Integer> list = new ArrayList<Integer>();
list.add(4);
list.add(6);
list.add(5);
list.add(9);
list.add(27);
int c=0;
for(int i=0; i<list.size(); i++)
{
    if(list.get(i)%3==0)
        c+=list.get(i)+1;
}
System.out.println(c);

What is printed as a result of executing the code segment?

A

3

B

15

C

42

D

45

E

51

Select an assignment template