Last updated 19 September 2026. Default examples are mid-level Spring and Java 17–21. Junior and senior sit in labeled sections so the first screen is not a fresher dump.
java.util collections are still the first twenty minutes of a Java interview. List, Set, Map, and the iterators that fail-fast. This hub is the collections head term. List, Set, and Map child topics stay as deep links; do not open three competing hubs for the same interview.
Junior
Collection is the root for List, Set, and Queue. Map is a separate hierarchy. List is ordered and allows duplicates. Set rejects duplicates via equals and hashCode. Queue is for producers and consumers. ArrayList is a resizable array. LinkedList is a doubly linked list; it is almost never the right default. HashSet is a HashMap with a dummy value. TreeSet is a red-black tree with a Comparator or natural order.
HashMap allows one null key. Hashtable allows none and is synchronized; do not use it. LinkedHashMap keeps insertion order. IdentityHashMap compares with ==. ConcurrentHashMap is the concurrent default. WeakHashMap keys can be collected; it is not a general-purpose map.
equals and hashCode must be consistent. Mutating a field that participates in hashCode after the object is in a HashSet loses the entry. Prefer immutable keys. Iterator.remove is the safe way to remove while iterating. Collection.remove inside a for-each throws ConcurrentModificationException on fail-fast iterators.
Arrays.asList returns a fixed-size list backed by the array. add throws. Changing the list writes through to the array. List.of and Set.of (Java 9+) are unmodifiable and reject nulls. That is a different contract than Arrays.asList.
Mid-level
ArrayList growth copies the array. Worst-case add is linear; amortized add is constant. LinkedList add at the end is constant, but get(i) is linear. Random access and memory locality usually win for ArrayList. Measure before you switch.
HashMap in Java 8+ treesifies long colliding bins. hashCode quality still matters. Capacity and load factor: default 16 and 0.75. resize rehashes. For a known size, size the map. ConcurrentHashMap does not lock the whole table; it uses bins and CASes. It does not allow null keys or values. size() is not a free atomic snapshot in the way juniors hope.
Comparators: natural order must be consistent with equals if you use the collection as a Set or Map key. TreeMap with a Comparator that disagrees with equals will violate the Set contract. NavigableMap gives headMap, tailMap, and ceiling keys. Those APIs are how mid-level candidates show they read the javadoc.
Concurrent collections: ConcurrentHashMap, CopyOnWriteArrayList, ConcurrentLinkedQueue, BlockingQueue implementations. CopyOnWrite is for rare writes and many reads, such as listener lists. It is not a faster ArrayList. BlockingQueue is the interview answer for a bounded handoff between threads.
Streams and collections: collect(toList()) was unmodifiable-or-not depending on version until toList() on Stream in Java 16 became an unmodifiable list. Say which API you mean.
Senior
Senior collections talk about memory layout, false sharing, and why ConcurrentHashMap.compute is atomic per key. replace, putIfAbsent, and merge are the tools; check-then-act on get plus put is a race. LinkedHashMap access-order plus removeEldestEntry is a simple LRU. It is not thread-safe.
Spliterators and parallel streams: the source must split well. parallel() on a tiny ArrayList is a net loss. The common ForkJoinPool is a process-wide resource; do not block in a parallel stream in a servlet thread without thinking about saturation.
Sequenced collections in Java 21 add addFirst, addLast, getFirst, getLast, and reversed views. List, LinkedHashSet, and LinkedHashMap participate. A reversed view is live, not a copy. Mutating the view mutates the original. That is the Java 21 collections interview, and it belongs here as well as on the Java 21 hub.
When a custom collection is justified: almost never. Primitive maps (fastutil, Eclipse Collections) are a measured performance choice, not a default.
Probe yourself
Why is LinkedList rarely the right List?
Pointer chasing and get(i) are linear. ArrayList wins on locality and random access for most interview and production cases.
What happens if you mutate a key after inserting it into a HashSet?
Its bucket is stale. You may not find it again. Use immutable keys.
Does ConcurrentHashMap allow a null value?
No. Null keys and null values are forbidden, unlike HashMap.
Related questions on this topic are linked below. Read the full answer on the question URL; this hub does not repeat those answers.
Pitfalls interviewers still use
Arrays.asList(array).add(x) throws UnsupportedOperationException. Candidates who say 'it returns an ArrayList' fail. It returns a private nested list. List.of is unmodifiable and rejects null. new ArrayList<>(List.of(...)) is the mutable copy.
HashMap is not thread-safe. A concurrent resize on old JDKs could livelock; on modern JDKs you still get lost updates and loops in custom code that assumes visibility. ConcurrentHashMap is the default shared map. Hashtable is not the answer.
TreeSet with a Comparator that returns 0 for unequal elements treats them as duplicates. That is how people lose data and then blame Set.
Fail-fast iterators throw ConcurrentModificationException when the collection is structurally changed by another iterator or by the collection methods. It is best-effort, not a synchronization tool. Do not catch CME as control flow.
Using LinkedList because 'we add at both ends' without measuring get/index use is a premature pessimization. ArrayDeque is the deque default.
For the room: pick a structure for a bounded producer-consumer, a LRU cache, and a unique insertion-ordered set. BlockingQueue, LinkedHashMap access-order, LinkedHashSet. If you say Vector, you are done.
How to answer in the room
Pick the interface first, then the class. List when order and duplicates matter. Set when uniqueness matters. Map when you look up by key. Queue or Deque when you hand work between stages. If you start with ArrayList every time, they will ask for the case that is not a List.
HashMap versus LinkedHashMap versus TreeMap versus ConcurrentHashMap is the map interview. Unordered, insertion or access order, sorted keys, concurrent writes. Hashtable is not the concurrent answer. IdentityHashMap uses ==. EnumMap is for enum keys. WeakHashMap is not a cache you want without thinking about identity and GC.
Unmodifiable versus immutable: List.of and Map.of reject null and are unmodifiable. Collections.unmodifiableList is a view; the backing list can still change. Arrays.asList is a fixed-size view of an array; add throws. Know which exception you get.
Iteration: fail-fast iterators on most java.util collections, weakly consistent on concurrent ones. ConcurrentModificationException is not a lock. Do not catch it as control flow. A structural change during iteration needs an iterator.remove or a concurrent collection.
Complexity: ArrayList get is O(1), add at end amortized O(1), add at front O(n). LinkedList is the opposite story and usually the wrong default. HashMap average O(1) until you ruin hashCode. TreeMap O(log n). Say the words, then say you would measure if the structure is on a hot path.
Java 21 sequenced collections add getFirst/getLast and reversed views. Mention them if the job is on 21. Do not pretend they exist on 8. Virtual threads do not change which collection you pick; they change how you share it.
This hub covers the list-set-map cluster as one page. Child pages for a single method stay. Do not spawn three competing 'interview questions' URLs for List, Set, and Map when the query is the framework.