Multiple choice general knowledge

import java.util.*; class Gen { T obj; Gen(T o){ obj=o; } T get() { return obj; } } class Generics19{ public static void main(String[] args){ Gen i1=new Gen(new Integer(10)); int i=i1.get(); System.out.println(i); } }

  1. Compiler Error

  2. Exception

  3. Prints 10

  4. Prints 0

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

The code uses Java generics with type inference. Gen is created, and when i1.get() returns an Integer, Java's autounboxing converts it to int automatically. This compiles and runs without error, printing 10. The generic type parameter T is inferred as Integer, making the assignment int i = i1.get() valid through autounboxing.