Interview replay
Full round replay — HashMap
Timed verbal replay with pass/fail criteria per follow-up.
How to run this
The opener
“How does HashMap work internally?”
Budget: 45 seconds. Going long here is itself a fail signal.
Follow-ups
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. “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. “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. “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. “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.