Treemap Flashcards

1
Q
  1. What is tree map
  2. Tree map Data structure
    3.Is Heterogenous objects support in Tree map
    4.What is Comparator in Tree map
  3. for Comparator can keys be Heterogenous?
  4. Can we insert user defined object values in Hashmap . yes refer Eclipse. Program User defined.
A
  1. TreeMap is used for Sorting
  2. REd- black tree, sorting is based on Keys
  3. No heterogenous is not supported in Tree Map
    class cast Exception will throw
    Because to do sorting we need Homogenous support
  4. if we have laptop - price
    Mobile -Price
    Iphone -price , we need to sort only price in that case for own sorting we can use this comparator
  5. Yes for Comparator Keys can be Heterogenous.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q
  1. What is legacy class.
  2. Hashtable is legacy class?
    3.Is there is any difference from Hashmap for the hashtable?
  3. What is Properties in Hashtable , how it will be useful?
A

1.So, classes and interfaces that formed the collections framework in the older version of Java are known as Legacy classes.
2.Yes Hashtable is a legacy class , also internal DS of hashmap is hashtable
3. No there is no difference , except the Properties class and it is a Key value.
4, Properties is maily used for testing purpose , in selenium or anyother testing , we can also load and get the properties file here .
we have store method too

How well did you know this?
1
Not at all
2
3
4
5
Perfectly