Java: Which practice avoids a common mistake with LRU Cache with LinkedHashMap?

Difficulty:

Medium

Questions:

1

Time Limit:

2 minutes

Passing Score:

100%

Question

Which practice avoids a common mistake with LRU Cache with LinkedHashMap?

  1. Ignore the LRU Cache with LinkedHashMap issue and rely on team discipline instead of APIs or contracts.
  2. Silence the LRU Cache with LinkedHashMap problem by using raw types, broad catches, or shared mutable state.
  3. Do not describe LinkedHashMap as a complete production cache solution without considering concurrency, metrics, and eviction policy details.
  4. Prefer the version of LRU Cache with LinkedHashMap 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 describe LinkedHashMap as a complete production cache solution without considering concurrency, metrics, and eviction policy details.

Do not describe LinkedHashMap as a complete production cache solution without considering concurrency, metrics, and eviction policy details. This is a common failure mode in real Java code and a frequent interview follow-up.

Track: Java