Skills101
← All practice quizzes

Quiz: Wrapper Classes and Autoboxing

5 questions · new set on every retakeNo time limitPass: 60%+10 XP on first pass

Why Java needs Integer as well as int, what autoboxing really does, why 127 == 127 is true but 128 == 128 is false, and the NullPointerException hiding in unboxing.

Log in to take the quiz

Free account · see your score, answers and explanations, earn XP

  1. Question 1

    What does this print?

    public class Main {
        public static void main(String[] args) {
            Integer x = 100, y = 100;
            Integer p = 1000, q = 1000;
            System.out.println((x == y) + " " + (p == q));
        }
    }
    
  2. Question 2

    What does the compiler turn Integer n = 42; into?

  3. Question 3

    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));
        }
    }
    
  4. Question 4

    Which line can throw a NullPointerException even though it calls no method?

  5. Question 5

    What is the safest way to compare the values of two Integer variables a and b?

🎯 Today’s placement challenge — 10 questions, no login. Can you score 10/10?Take today’s challenge →