Multiple choice

How many constructors of ConcurrentHashMap class are there in Java collections framework?

  1. 8

  2. 7

  3. 6

  4. 5

  5. 4

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

This is the correct choice because there are 5 constructors of ConcurrentHashMap class. These are:

1) ConcurrentHashMap(): creates a new, empty map with a default initial capacity (16), load factor (0.75) and concurrencyLevel (16) 2) ConcurrentHashMap(int initialCapacity): creates a new, empty map with specified initial capacity and with default load factor (0.75) and concurrencyLevel (16) 3) ConcurrentHashMap(int initialCapacity, float loadFactor): creates a new, empty map with specified initial capacity and load factor, and with the default concurrencyLevel (16) 4) ConcurrentHashMap(int initialCapacity, float loadFactor, int concurrencyLevel): creates a new, empty map with specified initial capacity, load factor and concurrencyLevel 5) ConcurrentHashMap(Map m): creates a new map with the same mappings as the given map