Multiple choice

How many constructors of HashMap class are there in java collections framework?

  1. 6

  2. 5

  3. 4

  4. 3

  5. 2

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

This is correct, as there are 4 constructors of HashMap class. These are :-HashMap() :- Constructs an empty HashMap with the default initial capacity (16) and the default load factor (0.75). HashMap(int initialCapacity) :- Constructs an empty HashMap with the specified initial capacity and the default load factor (0.75). HashMap(int initialCapacity, float loadFactor) :- Constructs an empty HashMap with the specified initial capacity and load factor. HashMap(Map<? extends K,? extends V> m) :- Constructs a new HashMap with the same mappings as the specified Map.