wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes sets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "sets" Watch "sets" New topic
Author

sets

nitin sharma
Ranch Hand

Joined: Feb 24, 2001
Posts: 290
Which option does not allow the duplicates to be stored.
1)java awt.util.Set
2)java.util.List
3)java.util.SortedSet
4) java.util.Map
I think (1),(3),(4) are correct.Please correct me if im wrong.
Tracy Qi
Ranch Hand

Joined: Apr 23, 2001
Posts: 37
I think the only choice is 1. Set. It won't allow duplicates. Couldn't find java.util.SortedSet anywhere.
basically there are two types of collections:
Collection: SET - No duplicates
List - Ordered
Map: a et of mappings or associations between objects.

Hope this help.
Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
Hi Nitin,
The question is worded very badly! If you typed in the choices correctly then the answers would be: 3 (for sure) and 4 (maybe)
Reasons:
1. No such class, interface, or package exists
2. List interface allows duplicates
3. SortedSet extends java.util.Set interface and does not allow duplicates
4. If we take the key-value pair as a stored value then the java.util.Map doesn't allow duplicates. If we are only talking about value then Map does allow duplicates.

Regards,
Manfred.
Ravindra Mohan
Ranch Hand

Joined: Mar 16, 2001
Posts: 216
Hi Nitin,
I agree with Manfred, your question is a bit wrongly worded, but the answer is as follows:
Basically <code> Collection </code> is an interface
under <code> java.util package </code> This interface is extended by other interfaces viz., <code> BeanContext, BeanContextServices, Set , SortedSet , List </code>. Of the five listed above only <code> Set and SortedSet </code> do not allow duplicates element to be added to the container. On the other hand <code> SortedMap </code> though not a part of <code>Collection </code> interface is part of Collection framework and it impliments the <code> Map </code> interface, and it does not allow duplicate values to be added to
the container having them (as pointed by Mansfeld in his code). So the correct answer would be (1) , (3) and (4).
Hope this suffices your querry.
Rgds,
Ravindra Mohan.

[This message has been edited by Ravindra Mohan (edited May 03, 2001).]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: sets
 
Similar Threads
Combinational Calculation generation
Q. for ejb deployment descriptor
Help me put my confusion to rest
am confusing in operator precednce pls explain me
What will be the output ?