my dog learned polymorphism*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes K&B Chapter 7 Question 7 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "K&B Chapter 7 Question 7" Watch "K&B Chapter 7 Question 7" New topic
Author

K&B Chapter 7 Question 7

Douglas Boff Nandi
Ranch Hand

Joined: Feb 25, 2008
Posts: 34
Which collection class(es) allows you to grow or shrink its size and provides indexed access to its elements, but whose methods are not synchronized?
A. java.util.HashSet
B. java.util.LinkedHashSet
C. java.util.List
D. java.util.ArrayList
E. java.util.Vector
F. java.util.PriorityQueue

Answer: only D

I think the B is a correct answer too.

From Java API:LinkedHashSet: This linked list defines the iteration ordering, which is the order in which elements were inserted into the set.
Morteza Manavi-Parast
Ranch Hand

Joined: Dec 25, 2008
Posts: 66
No. That's not right. The only part of the collection which you can get by index is the classes who implement the List interface (Like ArrayList). The signature of the method is: get(int index)
And if you look at the java documentation for LinkedHashSet again, you'll see that you can not find such a method for Set and its implementers.

SCJP 6
Douglas Boff Nandi
Ranch Hand

Joined: Feb 25, 2008
Posts: 34
Now I understand. Thank you!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: K&B Chapter 7 Question 7
 
Similar Threads
About vector
collections!
questions on java.util package - Part 3
JavaCaps mock 1 Q:51
pls help me.