What are the Differences between map and hashmap?



What are the Differences between map and hashmap?..

Answer / Rahul Yadav

Map and HashMap are both implementations of Map interface in Java. Here are their key differences:n
1. Implementation: HashMap is a concrete implementation of the Map interface, while Map is an abstract class that provides a common interface for various concrete implementations (such as HashMap, TreeMap, LinkedHashMap, etc.).n
2. Default Initial Capacity and Load Factor: The default initial capacity and load factor of HashMap are 16 and 0.75, respectively. These values can be customized when creating a new instance of HashMap.n
3. Ordering: HashMap does not maintain any ordering for its keys (neither insertion order nor sort order). TreeMap, on the other hand, stores keys in sorted order based on their natural ordering or a custom Comparator provided by the user.n
4. Null Keys and Values: Both HashMap and Map allow one null key but not more than one, and both can have multiple null values.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Data Structures Interview Questions

Why concurrenthashmap is fail safe?

1 Answers  


How many types of linked lists are there?

1 Answers  


What is structure of data type?

1 Answers  


Can you provide some implementation of a dictionary having large number of words?

1 Answers  


Define linear probing?

1 Answers  


List the applications of set adt?

1 Answers  


How many links are there in a binary tree of N nodes?

1 Answers   Tech Mahindra,


Explain pre-order and in-order tree traversal.

1 Answers  


What do you mean by probing?

1 Answers  


Can arraylist be empty?

1 Answers  


Differentiate between hashset and treeset.

1 Answers  


What is bubble sort technique?

1 Answers  


Categories