Which collection would be the best one to use, if you were working with a Student Information management web application that needs to maintain and search students, stored as instances of a class 'Student'.
You should be able to perform the following:
i) identify a Student by its unique alphanumeric identification number.
ii) Print out the Student in order of their unique identification numbers
Answer : D (TreeMap)
Option D is correct. Both HashMap and TreeMap enable storing a 'key' and a 'value' combination, where the values and keys can be objects, and the objects are searchable on their keys. However, only TreeMap maintains the natural order of the keys.
source are : http://www.cafe4java.com/mockexams/scjp/mock3/a1.php
could you please show me why the true answer is D? even the question asks for a collection and map is not a collection.