This week's book giveaway is in the OCAJP forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line!
See this thread for details.
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


Win a copy of OCA Java SE 8 Programmer I Study Guide 1Z0-808 this week in the OCAJP forum!
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!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: K&B Chapter 7 Question 7