Oracle interview question

Methods present in HashMap Class

Interview Answer

Anonymous

7 May 2020

HashMap is the HashTable implementation of the Map interface : In HashMap the data is stored in the form of key-value pair.It allows null value and null key Methods in HashMap class are: 1.clear() clears all the current mappings in the hashmap and returns void. 2.size() returns int value which gives the number if key-value mappings in the hashmap. 3.put(key k,value v) maps the specified key with the specified value in the Map. 4.remove(key k) removes the specified key from the map 5.isEmpty() returns true if there are no key-value mappings in the map. 6.get(key k) returns the value associated with the key. 7.getOrDefault(key k, default value) returns the value if its present with the key else return default value specified;