
Java interview prep
Collections Framework Deep Dive 1️⃣ Why does HashMap allow one null key but Hashtable doesn’t? Short Answer: HashMap was designed for modern multi-threaded applications with null-safe design; Hashtable predates this and was optimized for thread-safety by rejecting nulls outright. Detailed Explanation: Hashtable uses the hashCode() method on every key. If you pass null, it throws a NullPointerException immediately—no comparison, no storage. This is intentional: it forces you to know your data upfront. ...