← 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);
}
}
- A.true
- B.false
- C.Compile error
- 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 →