this question is from examlab practice exam 2
Ques; the progrmmer wants to create a telephone directory,and that should be ordered implicitly in terms of its name and it could allow duplicate names in it also.........what should be used
for that
As per my understanding what i see is (i am not sure please see my below explaination for both collection and map) according to that nothing get fixed into the above scenerio
lets go one by one.........
here it is
set----it doesnot allow duplicate values and ordered is unpredictable and unsorted also
hashset----doesnot allow duplicate value and order is unpredictable and unsorted also
linkedhashset-->doesnot allow duplicate value and order is similer to data is inserted and unsorted
Treeset---->doesnot allow duplicate values but it is sorted and ordered also.
arraylist--->allow duplicate values but doesnot sort it and its method are also not synchronized
vector---->allow duplicate values but doesnot sort it and it method are sychronized
Hashmap--->doesnot allow duplicate keys.......but it sort it in natural order......null key is not there in it....it method are also not synchronized..
Hashtable--->doesnot allow duplicate keys.......but it sort it in natural order......one null key is allowed....it method are also synchronized..
linkedhashmap-->doesnot allow duplicate keys.....order is same as it is inserted......
priority queue---->elements are sorted in their natural ordering......
none from the above gets fixed into above scenerio..........as the above scenerio requires both duplicate key and they are also implicitly sorted by their name,
Thanks in advance..........
and please correct me if i am wrong in the my above explaination of the map and collection
Ques; the progrmmer wants to create a telephone directory,and that should be ordered implicitly in terms of its name and it could allow duplicate names in it also.........what should be used
for that
As per my understanding what i see is (i am not sure please see my below explaination for both collection and map) according to that nothing get fixed into the above scenerio
lets go one by one.........
here it is
set----it doesnot allow duplicate values and ordered is unpredictable and unsorted also
hashset----doesnot allow duplicate value and order is unpredictable and unsorted also
linkedhashset-->doesnot allow duplicate value and order is similer to data is inserted and unsorted
Treeset---->doesnot allow duplicate values but it is sorted and ordered also.
arraylist--->allow duplicate values but doesnot sort it and its method are also not synchronized
vector---->allow duplicate values but doesnot sort it and it method are sychronized
Hashmap--->doesnot allow duplicate keys.......but it sort it in natural order......null key is not there in it....it method are also not synchronized..
Hashtable--->doesnot allow duplicate keys.......but it sort it in natural order......one null key is allowed....it method are also synchronized..
linkedhashmap-->doesnot allow duplicate keys.....order is same as it is inserted......
priority queue---->elements are sorted in their natural ordering......
none from the above gets fixed into above scenerio..........as the above scenerio requires both duplicate key and they are also implicitly sorted by their name,
Thanks in advance..........
and please correct me if i am wrong in the my above explaination of the map and collection