← Quiz: Java Generics: all 10 questions
Quiz: Java Generics · Question 1 of 10
What is the main benefit of generics?
What is the main benefit of generics?
- A.Programs run faster because types are removed
- B.Type errors are caught at compile time and casts are not needed
- C.Collections can hold primitives directly
- D.Classes can extend many parents
Answer & explanation
Correct answer: Type errors are caught at compile time and casts are not needed
Generics let the compiler check element types, so wrong types are rejected early and reads need no cast.
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 →