1.

What happens if we put a key object in a HashMap which exists?(a) The new object replaces the older object(b) The new object is discarded(c) The old object is removed from the map(d) It throws an exception as the key already exists in the map

Answer» Correct answer is (a) The new object replaces the older object

To explain I would say: HashMap always contains unique keys. If same key is inserted again, the new object replaces the previous object.


Discussion

No Comment Found

Related InterviewSolutions