wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Dan's Collection: Duplicate elements must not replace old elements 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 "Dan Watch "Dan New topic
Author

Dan's Collection: Duplicate elements must not replace old elements

Cathy Song
Ranch Hand

Joined: Aug 24, 2003
Posts: 270

Question 4
� Each element must be unique.
� Duplicate elements must not replace old elements.
� Elements are not key/value pairs.
� Accessing an element can be almost as fast as performing a similar operation on an array.
Which of these classes provides the specified features?
a. LinkedList
b. TreeMap
c. TreeSet
d. HashMap
e. HashSet
f. LinkedHashMap
g. Hashtable
h. None of the above

What does this statement mean?
Duplicate elements must not replace old elements
Thanks.
Vad Fogel
Ranch Hand

Joined: Aug 25, 2003
Posts: 504
Hi Cathy, here's an excerpt from HashSet API:

add
public boolean add(Object o)Adds the specified element to this set if it is not already present.
Specified by:
add in interface Set
Overrides:
add in class AbstractCollection
Parameters:
o - element to be added to this set.
Returns:
true if the set did not already contain the specified element.


This mechanism doesn't replace the elements if duplicates are detected.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Dan's Collection: Duplicate elements must not replace old elements
 
Similar Threads
Dan's mock exam: collection classes
Dan's questions
Collection doubt from Dan's mock test
Collections from Dan's Exam
Problem with arraylist