Output:
<code>ArrayList<Integer> list = new ArrayList<>(); list.add(1); list.add(2); list.add(3); int s = 0; for (int x : list) s += x; System.out.println(s); </code></pre>
- A
9
- B
12
- Ccheck_circle
6
- D
3
Explanation
Sum 1 + 2 + 3 = 6.
AP Computer Science A· difficulty 4/5
Output:
<code>ArrayList<Integer> list = new ArrayList<>(); list.add(1); list.add(2); list.add(3); int s = 0; for (int x : list) s += x; System.out.println(s); </code></pre>
9
12
6
3
Explanation
Sum 1 + 2 + 3 = 6.
Want 10 more like this — adaptive to your weak spots?