Govt Exams
LinkedHashSet maintains insertion order using a doubly-linked list. HashSet does not maintain order, TreeSet maintains sorted order, and ConcurrentHashMap doesn't guarantee insertion order.
HashMap uses a hash table with buckets (arrays of linked lists or red-black trees) to store key-value pairs for efficient O(1) average lookup time.
Set interface explicitly does not allow duplicate elements. List allows duplicates, Queue is for ordered collections, and Map stores key-value pairs.
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.
Java 9 introduced factory methods like List.of(), Set.of(), Map.of() for creating immutable collections.
collection.stream() returns a sequential stream, while parallelStream() returns a parallel stream.