Home » JAVA Programming » Collections » Question
  1. What happens if we put a key object in a HashMap which exists?
    1. The old object is removed from the map
    2. It throws an exception as the key already exists in the map
    3. The new object replaces the older object
    4. The new object is discarded
    5. None of these
Correct Option: C

HashMap always contains unique keys. If same key is inserted again, the new object replaces the previous object.



Your comments will be displayed only after manual approval.