By a chance it happened to me twice that I got the same Java question during a job interview Java test. For me it seems like a nonsense. It goes something like this:
Which of this collections would you use if you needed a collection with no duplicates and with natural ordering?
- java.util.List
- java.util.Map
- java.util.Set
- java.util.Collection
The closest answer would be Set
. But as far as I know these interfaces, with exception of List
do not define any ordering in their contract but it is the matter of the implementing classes to have or not to have defined ordering.
Was I right in pointing out in the test that the question is wrong?