Multiple choice technology programming languages

What will be outcome of following code? List list = new ArrayList(); list.add(0, new Integer(42)); int total = list.get(0); System.out.println(total);

  1. 42

  2. Compilation Error - Incompatible Type

  3. Runtime Error - Java.lang.ClassCastException

  4. None of above

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

The code correctly adds Integer 42 at index 0, then retrieves it using get(0). Since autounboxing converts Integer to int automatically when assigning to the int variable 'total', the output is 42. There is no compilation error (types are compatible) and no ClassCastException (autounboxing handles the conversion).