6 topics · 0/6 read
Java Collections Framework
The collections hierarchy, how HashMap works inside, ArrayList vs LinkedList, ConcurrentHashMap, Comparable vs Comparator, and fail-fast vs fail-safe iterators.
Collections Hierarchy: List, Set, Queue and Map
The Java Collections Framework gives you List, Set, Queue and Map with several implementations each. Choosing the right one by ordering, duplicates and time complexity is a basic Java interview skill.
Read nowHow HashMap Works Internally
How HashMap works internally is probably the most asked Java question. You should explain hashing to buckets, collisions, treeification in Java 8, the load factor and resizing, and why HashMap is not thread-safe.
Read nowArrayList vs LinkedList
ArrayList vs LinkedList is a favourite question because the textbook answer ("LinkedList is faster for inserts") is mostly wrong in practice. ArrayList wins almost every real workload because of memory locality.
Read nowConcurrentHashMap and Thread-Safe Collections
ConcurrentHashMap is the go-to map for shared state between threads. Interviewers ask how it stays thread-safe without locking the whole map, how it differs from Collections.synchronizedMap, and how to update values atom
Read nowComparable vs Comparator and Sorting
Comparable defines an object's natural order inside the class; Comparator defines any number of external orders. Sorting objects by several fields with Comparator chains is a common live-coding task.
Read nowFail-Fast vs Fail-Safe Iterators
Fail-fast iterators throw ConcurrentModificationException when a collection changes during iteration; fail-safe (weakly consistent) iterators work on a snapshot or tolerate changes. Interviewers ask how it works and how
Read now