Multiple choice technology programming languages

What is the output for the below code ? public class Test { public static void main(String[] args) { List list = new ArrayList(); list.add(0, 59); int total = list.get(0); System.out.println(total); } }

  1. 59

  2. Compile time error, because you have to do int total = ((Integer)(list.get(0))).intValue();

  3. Compile time error, because can't add primitive type in List.

  4. Compile Properly but Runtime Exception

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

Java's compiler handles autoboxing and unboxing automatically. The primitive int value 59 is autoboxed into an Integer when added to the list, and then automatically unboxed back to an int when retrieved using list.get(0), making the code correct and printing 59 without errors.