Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JXAM: Vector vs. List

 
David Wake
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 214
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But List is an interface, not a class. How could it be the answer to the question?
 
Jane Griscti
Ranch Hand
Posts: 3141
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Percy Densmore
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Except that the question does ask for a class and List is not a class.
------------------
Tom - SCJP --- Co-Moderator of the Programmer Certification Forums
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic