← Quiz: Java Generics: all 10 questions
Quiz: Java Generics · Question 4 of 10
Which parameter type lets a method ADD Integer values to a List<Number or a List<Object?
Which parameter type lets a method ADD Integer values to a List<Number> or a List<Object>?
- A.List<? extends Integer>
- B.List<Integer>
- C.List<?>
- D.List<? super Integer>
Answer & explanation
Correct answer: List<? super Integer>
A consumer uses super: any list whose type is Integer or a parent of Integer can safely take Integers.
Can you get the rest right without peeking?
Take the timed Quiz: Java Generics quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →