Treemap Flashcards
1
Q
- What is tree map
- Tree map Data structure
3.Is Heterogenous objects support in Tree map
4.What is Comparator in Tree map - for Comparator can keys be Heterogenous?
- Can we insert user defined object values in Hashmap . yes refer Eclipse. Program User defined.
A
- TreeMap is used for Sorting
- REd- black tree, sorting is based on Keys
- No heterogenous is not supported in Tree Map
class cast Exception will throw
Because to do sorting we need Homogenous support - 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 - Yes for Comparator Keys can be Heterogenous.
2
Q
- What is legacy class.
- Hashtable is legacy class?
3.Is there is any difference from Hashmap for the hashtable? - 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