Govt Exams
ArrayList.add() has O(1) amortized time complexity. When capacity is exceeded, resizing takes O(n).
The correct hierarchy is Iterable (interface) -> Collection -> List/Set/Queue/Deque interfaces.
poll() returns null if the queue is empty, while remove() throws NoSuchElementException.
Hashtable is a legacy synchronized collection class. HashMap, ArrayList, and TreeSet are not synchronized by default.
HashMap has a default initial capacity of 16 and a load factor of 0.75.
Set interface does not allow duplicate elements, while List, Queue, and Collection support duplicates.
CopyOnWriteArrayList is optimal for read-heavy concurrent operations. It creates copy on write, allowing safe concurrent reads.
Java 9 introduced factory methods like List.of(), Set.of(), Map.of() for creating immutable collections.
List list = Arrays.asList(5, 2, 8, 1);
All three approaches work correctly for reverse sorting. Options A, B, and C are all valid Java code.
LinkedHashMap with accessOrder=true maintains access-order. get() moves the element to the end (LRU cache behavior).