How many null keys can a java.util.HashMap hold?
Correct answer C. At most one
Explanation
HashMap permits null values and a single null key. Since keys must be unique, putting a second entry with a null key simply replaces the first one's value. This differs from Hashtable and ConcurrentHashMap, which reject null keys outright by throwing NullPointerException, a common point of confusion when replacing one map type with another.
Answer checked How we write and check questions
Discussion