Entrance Exams
Govt. Exams
ConcurrentHashMap uses segment-based locking allowing safe iteration during concurrent modifications. HashMap throws ConcurrentModificationException.
Records (Java 14+) provide compact syntax for data carriers used with collections, improving performance and readability.
Collections.frequency() correctly handles null values and returns the count of null elements in the collection.
lower() returns the greatest element < given element. floor() returns <= element.
Iterator.next() throws NoSuchElementException when hasNext() returns false and next() is called.
TreeSet maintains sorted order (O(log n) insertion/deletion) using a Red-Black tree structure.
ListIterator extends Iterator and provides bidirectional traversal using previous() and next() methods.
CopyOnWriteArrayList maintains insertion order and is thread-safe. It creates a copy of the array on modification.
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.