Multiple choice technology programming languages

What will be output for the following program? public class BoxingTest { public static void main(String[] args) { byte b = 10; method(b); } static void method(int i){ System.out.println("Primitive Type call"); } static void method(Integer i){ System.out.println("Wrapper Type Call"); } }

  1. Wrapper Type Call

  2. Primitive Type Call

  3. Compiler Error

  4. Compiles fine, throws runtime exception

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

When passing a byte to an overloaded method, Java chooses between widening conversion (byte to int, calling the primitive method) and autoboxing (byte to Byte, which doesn't match Integer). Widening wins over autoboxing, so method(int i) is called, printing 'Primitive Type call'.