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.
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.
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).]