🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Wrapper Classes and Autoboxing: all 10 questions

Quiz: Wrapper Classes and Autoboxing · Question 6 of 10

What does this print? (code)

What does this print?

public class Main {
    public static void main(String[] args) {
        Integer a = 500;
        int b = 500;
        System.out.println(a == b);
    }
}
  1. A.true
  2. B.false
  3. C.Compile error
  4. D.NullPointerException
Answer & explanation

Correct answer: true

When one side of == is a primitive int, the Integer is unboxed and the two numbers are compared.

Can you get the rest right without peeking?

Take the timed Quiz: Wrapper Classes and Autoboxing quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →