ArrayList<Integer> list = new ArrayList<>();
list.add(7);
list.add(8);
int x = list.get(0) + list.get(1);
System.out.println(x);What is printed?
- A
Compile-time error
- B
7
- Ccheck_circle
15
- D
78
Explanation
Autoboxing converts int 7 and 8 into Integer objects when added. Auto-unboxing converts them back to int when adding, producing 15.