Govt Exams
TreeMap implements NavigableMap which provides methods like higherKey(), lowerKey(), floorEntry(), etc.
LinkedHashMap map = new LinkedHashMap();
map.put("A", 1);
map.put("B", 2);
map.put("C", 3);
for(String key : map.keySet()) System.out.print(key);
LinkedHashMap maintains insertion order. Elements are iterated in the order they were inserted.
The add() method in Set returns boolean - true if element is added, false if duplicate exists.
TreeSet maintains elements in sorted order using Red-Black tree. HashSet is unordered and uses hash table for storage.
Set interface implementations like HashSet do not allow duplicates. Lists (ArrayList, LinkedList, Vector) allow duplicates.
ArrayList is backed by a resizable array providing O(1) random access. LinkedList uses doubly-linked list providing O(1) insertion/deletion at ends but O(n) for random access.
LinkedHashSet maintains insertion order using doubly-linked list. HashSet doesn't maintain order, TreeSet maintains sorted order, HashMap doesn't maintain insertion order.
HashMap provides O(1) average time complexity for get() operation. In worst case with hash collisions, it can be O(n).
HashMap implements the Map interface which stores key-value pairs. It does not implement Collection, List, or Set interfaces directly.
The 'final' keyword prevents a class from being extended. 'sealed' (Java 17+) allows selective subclassing, but 'final' is the standard way to prevent all subclassing.