Ctrl K
Java · Mid-level · Theory

Why 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>?

~4 min by voice

How to approach it

This checks whether the candidate understands the Java generics model: type erasure and its consequences, as well as invariance and applying wildcards deliberately according to PECS rather than by guesswork.

Have you seen this question in a real interview?
Answers0
Avg. score—
Strong—
Practiced0
Topics
Similar questionsWhy does Java have generics, and what is type erasure? JuniorTell 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