🎙 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 3 of 10

What does this print? (code)

What does this print?

public class Main {
    public static void main(String[] args) {
        Long a = 10L;
        System.out.println(a.equals(10) + " " + a.equals(10L));
    }
}
  1. A.true true
  2. B.false false
  3. C.true false
  4. D.false true
Answer & explanation

Correct answer: false true

10 is boxed to an Integer, and Long.equals returns false for any object that is not a Long.

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 →