← Quiz: Java Generics: all 10 questions
Quiz: Java Generics · Question 10 of 10
Why can't you write List<int?
Why can't you write List<int>?
- A.int is too small
- B.Lists can only hold Strings
- C.Type arguments must be reference types; use List<Integer>
- D.Because int is final
Answer & explanation
Correct answer: Type arguments must be reference types; use List<Integer>
Generics work with objects only. Autoboxing converts between int and Integer for you.
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 →