| Author |
Collection
|
preeti khane
Ranch Hand
Joined: Mar 12, 2003
Posts: 93
|
|
Which of these statements concerning the collection interfaces are true? 1) Set extends Collection. 2) All methods defined in Set are also defined in Collection. 3) List extends Collection. 4) All methods defined in List are also defined in Collection. 5) Map extends Collection. Answer is 1,2,3 I thought it was 1,2 I mean if Set extends then how can evrything in Set be defined in Collecion
|
 |
Manish Hatwalne
Ranch Hand
Joined: Sep 22, 2001
Posts: 2573
|
|
Originally posted by preeti khane: Which of these statements concerning the collection interfaces are true? 1) Set extends Collection. 2) All methods defined in Set are also defined in Collection. 3) List extends Collection. 4) All methods defined in List are also defined in Collection. 5) Map extends Collection. Answer is 1,2,3 I thought it was 1,2 I mean if Set extends then how can evrything in Set be defined in Collecion
I think, you meant you thought 1 and 3 were correct. As for Set, it contains no methods of its own, all its methods are inherited from Collection, hence 2 is correct. HTH, - Manish
|
 |
preeti khane
Ranch Hand
Joined: Mar 12, 2003
Posts: 93
|
|
manish, yes I meant 1,3 I see now , Set is an interface with no methods of its own.. kept thinking it was a concrete implementation... duh!! thanks
|
 |
Pallavi Chakraborty
Ranch Hand
Joined: Jan 18, 2003
Posts: 93
|
|
Hey everybody, What about option 4 ? Pallavi
|
 |
Rattan Mann
Ranch Hand
Joined: Jan 21, 2003
Posts: 44
|
|
Map does not extend Collection.Collection is a set of elements but map is a key-value pair. So Map and SortedMap (which extends Map)form a group of their own. Finally, HashMap implements Map. Rattan
|
 |
Rattan Mann
Ranch Hand
Joined: Jan 21, 2003
Posts: 44
|
|
Map does not extend Collection.Collection is a set of elements but map is a key-value pair. So Map and SortedMap (which extends Map)form a group of their own. Finally, HashMap implements Map. Rattan
|
 |
Monisha Talwar
Ranch Hand
Joined: Feb 11, 2003
Posts: 102
|
|
|
What about list? Does it have its own methods? Besides what it gets from Collection?
|
Hey! It compiles! Ship it!
|
 |
William Brogden
Author and all-around good cowpoke
Rancher
Joined: Mar 22, 2000
Posts: 12271
|
|
Thats the kind of question you should be answering by referring to the JavaDocs for the java.util package. Bill
|
 |
Rattan Mann
Ranch Hand
Joined: Jan 21, 2003
Posts: 44
|
|
As Bill says, this can be found out easily from APIs and docs. Moreover, set having no more methods than collection is more of an exception than a rule. In general, if there are no more (behaviour-specific) methods in subinterfaces then what is the point of extension! List definitely has more methods which are list-specific. Rattan
|
 |
 |
|
|
subject: Collection
|
|
|