Morgan Stanley interview question

Can a hashmap have multiple null keys?

Interview Answer

Anonymous

3 Aug 2011

No. HashMap is allowed to have only 1 null. If you try to add a second entry with null key, instead of a new entry the previous entry gets updated, i.e., the value is overwritten.

1