Interview replay

Full round replay — HashMap

10 minintermediate28 yrs

Timed verbal replay with pass/fail criteria per follow-up.

How to run this

Answer out loud, timed. Do not read the entry first. Then compare against "The Answer" and "Interviewer's Next Move" and mark yourself.

The opener

How does HashMap work internally?

Budget: 45 seconds. Going long here is itself a fail signal.

Follow-ups

  1. 1. “You said it treeifies at 8 nodes. Always?

    Testing: Do they know MIN_TREEIFY_CAPACITY = 64?

    Scoring

    Pass: Names the second condition — table must be >= 64, else it resizes instead.

    Fail: Repeats '8' with more confidence.

  2. 2. “Why must capacity be a power of two?

    Testing: Do they know the index is a bitmask, not a modulo?

    Scoring

    Pass: (n-1) & hash is cheaper than %, and it makes resize a single bit test.

    Fail: 'It's just convention' or 'for performance' with no mechanism.

  3. 3. “What happens if hashCode() returns a constant?

    Testing: Correctness vs performance separation.

    Scoring

    Pass: Still correct. Every entry collides; O(n) degrading to O(log n) after treeify.

    Fail: Says it breaks or throws.

  4. 4. “Java 8 fixed the infinite loop. Is HashMap thread-safe now?

    Testing: The single most common false belief on this topic.

    Scoring

    Pass: No. That fixed one livelock; there is still no synchronization. Lost updates, corrupted size.

    Fail: Yes / 'mostly' / 'if you don't resize'.

  5. 5. “ConcurrentHashMap instead of Collections.synchronizedMap — why?

    Testing: Lock granularity.

    Scoring

    Pass: Per-bin locking on write, lock-free reads, vs one monitor over the whole map.

    Fail: 'It's newer' or 'it's faster' with no mechanism.

Score yourself

5/5 — you can hold this topic at senior level 3-4 — solid; reread "Interviewer's Next Move" 0-2 — reread "Understand It" and redo the Challenge tier

← Back to How does HashMap work internally?