| preferred AP College board partner for AP classes
AP Computer Science A/Unit 7: ArrayList
Start Practice TestPractice Test
About Exam
medium Solved by 3 students
Tracing an ArrayList and For-Each Loop
< Prev
Next >

What is printed when the following code segment is executed?

int total = 3;
ArrayList<Integer> integerList = new ArrayList<Integer>();
for (int k = 7; k < 11; k++)
{
    integerList.add(k + 3);
}
for (Integer i : integerList)
{
    total += i;
    if (total % 2 == 1)
    {
        total -= 1;
    }
}
System.out.println(total);
A

34

B

47

C

49

D

46

Hint
Did You Know?
Explain Why
Explain All Answers
Check Answer
Show Correct Answer
Report Question

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Time
Score
#1kaisuki12 0m 00s 90
#2y.seong202723 5m 56s -166
#3chunxiangxu.cxu01 1h 46m -6,412
Items per page:
10
1 – 3 of 3

AI Tutor

How can I help?

APFIVE © 2020.
Email: apfive@apfive.org|Privacy Policy