🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← All topics

Quiz: Wrapper Classes and Autoboxing: questions with answers

10 questions, each with the answer and a short explanation.

Take the timed quiz + get a certificate →
  1. Q1. What does this print? (code)
  2. Q2. What does the compiler turn Integer n = 42; into?
  3. Q3. What does this print? (code)
  4. Q4. Which line can throw a NullPointerException even though it calls no method?
  5. Q5. What is the safest way to compare the values of two Integer variables a and b?
  6. Q6. What does this print? (code)
  7. Q7. Which wrapper class has NO value cache?
  8. Q8. What is the difference between Integer.parseInt("7") and Integer.valueOf("7")?
  9. Q9. Why is Long sum = 0L; for (long i = 0; i < n; i++) sum += i; slow?
  10. Q10. What does this print? (code)