When to use a Map in java?
Lists and Maps are different data structures. Maps are used for when you want to associate a key with a value and Lists are an ordered collection.
How does HashMap work?
Difference between Arraylist and Vector.
Difference between Arraylist and LinkedList.
When to use ArrayList and LinkedList?
Difference between HashMap and Hashtable.
Difference between HashMap and HashSet.
How can we sort a list of object based on it’s property?
Difference between Iterator and Enumeration interface in Java.
The functionality of Enumeration and the Iterator are almost the same. You can use remove() in an Iterator to remove any element, while Enumeration doesn’t provide remove() method. Using Enumeration, we can traverse and fetch the objects, whereas using Iterator, we can add and remove the objects as well. Therefore, Iterator can be useful if you want to manipulate the list and Enumeration is for read-only access. Also, Enumeration is only applicable for legacy classes e.g Hashtable, Vector.
How to iterate a HashMap?
// Get a set of the entries
Set set = hm.entrySet();
// Get an iterator
Iterator i = set.iterator();
// Display elements
Map.Entry me = (Map.Entry)i.next();
System.out.print(me.getKey() + ": ");
Note that these questions are from the most recent interview confrontations and are the most relevant ones.