Ctrl K
Java · Junior · Theory

Why does Java have generics, and what is type erasure?

~4 min by voice

How to approach it

This checks whether you understand that generics are a compiler mechanism for type safety, not a runtime feature, and whether you know the consequences of type erasure and the rules for working with wildcards.

Have you seen this question in a real interview?
Answers0
Avg. score—
Strong—
Practiced0
Topics
Similar questionsWhy can't you write new T() or check instanceof List<String> in Java? And how do you choose between List<? extends Number> and List<? super Integer>? Mid-levelTell me about type erasure in Java generics. What limitations does it impose, and how do you use wildcard types when designing an API? Senior

Answer by voice

The interviewer will ask this question and listen. Think out loud and ask for a hint if you need one. When you're done, pause or tap “That's my answer”. In about a minute, your score and the points you covered show up here.

Sign in to answer

Best with headphones · ~4 min