Java Programming - Objects and Collections - Discussion

Ashok said: (Jun 6, 2011)  
I think its wrong because as the question is like collection that don't allow duplicate elements not the keys, so it must be option D.

Chandra said: (Jun 14, 2011)  
Map allow duplicates but I will overide with previous value. So we can, t say duplicate keys not allow.

Dave Hampton said: (Dec 7, 2011)  
The question is ambiguous. It does not refer to 'unique keys' - it just states 'no duplicates'. You can in fact have duplicate object values in a Map referenced by different keys. The answer to the question as it stands is java.util.Set which translates to answer D as it's not listed.

Saroj Kumar Das said: (Mar 14, 2012)  
See Map don't contain duplicate keys but it contain duplicate values, it may be uses HashMap. I think the answer is D.

Sonam said: (Sep 5, 2012)  
Yes, the correct answer is D because the answer is asking about duplicate elements not the duplicate keys.

Kirk said: (Apr 11, 2013)  
This is simply a confusingly worded question.

If you consider Key/Value pairs as the element then the answer is correct, however if you only care about the Value then the answer is wrong.

I got it wrong, but I think that considering the Key/Value pair as the element is probably more correct.

I'd still give 1/2 points for selecting Map !

Gautam Prusty said: (Apr 25, 2016)  
Here you have written that,

You need to store elements in a collection that guarantees that no duplicates are stored. Which one of the following interfaces provide that capability?

Ans- But, Map is not part of the collection, so the answer is (D).

Moiz Nagourwala said: (May 17, 2016)  
Can an interface provide any type of capability?

I guess we just can't do anything than specifying the contract in terms of methods. So there is no way to forbid duplicate entries as methods are abstract.

Post your comments here:

Name *:

Email   : (optional)

» Your comments will be displayed only after manual approval.