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