Question: "Choose the class that can hold multiple equal objects in an ordered way. A. Map B. Collection C. List D. Set E. Vector" JXAM Correct Answer: C. My answer: E. My reasoning: java.util.List is an interface, not a class. Quote from Sun's javadoc for java.util.List: "Lists TYPICALLY allow duplicate elements." (my caps). Whereas Vector always does so.
Percy Densmore
Ranch Hand
Joined: Mar 06, 2001
Posts: 214
posted
0
In my research I don't see Vector as being part of the collections framework, whereas 'List' seems to be the best one to hold equal objects due to the phrase "in an ordered way". Percy
Manfred Leonhardt
Ranch Hand
Joined: Jan 09, 2001
Posts: 1492
posted
0
Hi Percy, Your research must not have been to in-depth. The Vector class is listed under See Also on the first page of the Collections API! In answer to the question posed by David, I think List would be the best choice. My reasoning: Vector just uses List functionality to perform its job! Regards, Manfred.
Carlo Smits
Greenhorn
Joined: Jul 09, 2001
Posts: 22
posted
0
But List is an interface, not a class. How could it be the answer to the question?
Jane Griscti
Ranch Hand
Joined: Aug 30, 2000
Posts: 3141
posted
0
All the selections, except Vector, are interfaces. The question could have been worded 'choose the type'. Lists allow duplicates, and a Vector 'is a' list. It was retro-fitted in JDK 1.2 to fit into the Collections framework. Hope that helps. ------------------ Jane Griscti Sun Certified Programmer for the Java� 2 Platform
Manfred and Jane, Belated thanks for the API update on Vector. Using older books is dangerous. We agree on List though as the correct answer Percy
Thomas Paul
mister krabs
Ranch Hand
Joined: May 05, 2000
Posts: 13974
posted
0
Except that the question does ask for a class and List is not a class. ------------------ Tom - SCJP --- Co-Moderator of the Programmer Certification Forums