← 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 →- Q1. What is the main benefit of generics?
- Q2. What does this print? (code)
- Q3. Does List<Number nums = new ArrayList<Integer(); compile?
- Q4. Which parameter type lets a method ADD Integer values to a List<Number or a List<Object?
- Q5. In static <T extends Comparable<T T max(List<T list), why is the bound needed?
- Q6. What does this print? (code)
- Q7. Which of these is NOT allowed because of type erasure?
- Q8. What does PECS stand for?
- Q9. What does this print? (code)
- Q10. Why can't you write List<int?