File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

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.

Douglas Boff Nandi
Ranch Hand

Joined: Feb 25, 2008
Posts: 34
Now I understand. Thank you!
subject: K&B Chapter 7 Question 7
It's not a secret anymore!