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

Quiz: Java Generics: questions with answers

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

Take the timed quiz + get a certificate →
  1. Q1. What is the main benefit of generics?
  2. Q2. What does this print? (code)
  3. Q3. Does List<Number nums = new ArrayList<Integer(); compile?
  4. Q4. Which parameter type lets a method ADD Integer values to a List<Number or a List<Object?
  5. Q5. In static <T extends Comparable<T T max(List<T list), why is the bound needed?
  6. Q6. What does this print? (code)
  7. Q7. Which of these is NOT allowed because of type erasure?
  8. Q8. What does PECS stand for?
  9. Q9. What does this print? (code)
  10. Q10. Why can't you write List<int?