Multiple choice

How many constructors of TreeMap 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 the correct answer. There are four constructors of TreeMap. These are :-TreeMap():- create an empty Map, TreeMap(Comparator comp):- The second form constructs an empty tree-based map that is sorted by using the Comparator comp, TreeMap(Map m):- The third form initialises a tree map with the entries from m, which is sorted by using the natural order of the keys, and TreeMap(SortedMap sm):- The fourth form initialises a tree map with the entries from sm, which is sorted in the same order as sm.