Question
Which practice avoids a common mistake with ConcurrentSkipListMap?
- Ignore the ConcurrentSkipListMap issue and rely on team discipline instead of APIs or contracts.
- Silence the ConcurrentSkipListMap problem by using raw types, broad catches, or shared mutable state.
- Do not pick a skip-list map when you only need direct key lookup and do not care about sorted navigation.
- Prefer the version of ConcurrentSkipListMap that makes behavior less predictable as long as the code compiles.
Hint
Look for the option that protects correctness instead of hiding the problem.
Answer and rationale
Correct answer: C. Do not pick a skip-list map when you only need direct key lookup and do not care about sorted navigation.
Do not pick a skip-list map when you only need direct key lookup and do not care about sorted navigation. This is a common failure mode in real Java code and a frequent interview follow-up.
Track: Java