Multiple choice technology programming languages

What is the output for the below code ? public class Test { public static void main(String[] args) { Integer i = null; int j = i; System.out.println(j); } }

  1. 0

  2. Compile with error

  3. null

  4. NullPointerException

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

The code attempts to unbox a null Integer reference to a primitive int. Unboxing involves calling i.intValue(), which throws NullPointerException when i is null. The exception occurs before any output is produced.