🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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>?

  1. A.int is too small
  2. B.Lists can only hold Strings
  3. C.Type arguments must be reference types; use List<Integer>
  4. 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 →