📦 Section 4 · 30 questions
Collections
30 interview questions and answers in the Collections section.
Questions in this section
- What are the main Collection Framework interfaces
- What is the difference between List, Set and Queue
- What is the difference between ArrayList and LinkedList
- When to use ArrayList vs LinkedList
- What is the time complexity of operations in ArrayList
- What is the time complexity of operations in LinkedList
- What is Vector and how does it differ from ArrayList
- What is Stack
- What is Queue and what implementations exist
- What is Deque
- What is the difference between HashSet, LinkedHashSet and TreeSet
- How does HashSet work internally
- What is TreeSet and how does it work
- What is Map and what implementations exist
- What is the difference between HashMap, LinkedHashMap and TreeMap
- When to use TreeMap
- What is WeakHashMap
- What is ConcurrentHashMap
- How does ConcurrentHashMap ensure thread-safety
- What is CopyOnWriteArrayList
- When to use synchronized collections
- How to get a synchronized collection
- What is Collections.unmodifiableList()
- How does Collections.unmodifiableList() work internally
- What is the difference between Iterator and ListIterator
- What are fail-fast and fail-safe iterators
- What is ConcurrentModificationException
- How to properly remove elements during iteration
- What is Comparable and Comparator
- What operations does the Collection interface support
Study navigator
A structured compilation of 31 core questions designed to prepare software engineers for Junior 🟢, Middle 🟡, and Senior 🔴 Java technical interviews.
📋 All Questions
🗺️ Topic Dependency Map
┌──────────────────────────────────────────┐
│ 1. Collection Framework Overview │
│ Collection, List, Set, Queue, Map │
└──┬──────────┬──────────┬─────────────────┘
│ │ │
┌──────────┘ │ └──────────┐
▼ ▼ ▼
┌───────────────┐ ┌───────────────┐ ┌────────────────────┐
│ LIST (3-10) │ │ SET (11-13) │ │ MAP (14-20) │
│ 3. ArrayList │ │ 11. HashSet │ │ 14. Map overview │
│ vs Linked │ │ vs Linked │ │ 15. HashMap vs │
│ 4. When what │ │ vs Tree │ │ LinkedHashMap │
│ 5-6. Big O │ │ 12. HashSet │ │ vs TreeMap │
│ 7. Vector │ │ internals │ │ 16. When TreeMap │
│ 8. Stack │ │ 13. TreeSet │ │ 17. WeakHashMap │
│ 9. Queue │ │ │ │ 18-19. CHM │
│ 10. Deque │ │ │ │ 20. CopyOnWrite │
└───────┬───────┘ └───────┬───────┘ └────────┬───────────┘
│ │ │
└────────────────────┼─────────────────────┘
▼
┌──────────────────────────────────────────┐
│ THREAD-SAFETY (18-22) │
│ 18-19. ConcurrentHashMap │
│ 20. CopyOnWriteArrayList │
│ 21-22. synchronized collections │
└──────────────────────────────────────────┘
┌──────────────────────────────────────────┐
│ ITERATORS & MUTATION (23-28) │
│ 23-24. unmodifiableList │
│ 25. Iterator vs ListIterator │
│ 26. fail-fast vs fail-safe │
│ 27. ConcurrentModificationException │
│ 28. Safe removal patterns │
└──────────────────────────────────────────┘
┌──────────────────────────────────────────┐
│ COMPARISON & CORE CONTRACTS (29, 31) │
│ 29. Comparable vs Comparator │
│ 31. Collection Operations │
└──────────────────────────────────────────┘
🎯 Recommended Study Tracks
🟢 Junior Level Track (Fundamentals)
- Framework Hierarchy: Q1, Q2, Q31 (Collection, List, Set, Queue, Map contracts).
- List Implementations: Q3, Q4 (
ArrayListvsLinkedList). - Queue & Legacy Structures: Q7, Q8, Q9, Q10 (
Vector,Stack,Queue,Deque,ArrayDeque). - Sets & Maps: Q11, Q13, Q14, Q15 (
HashSet,TreeSet,HashMap,TreeMap). - Iteration & Protection: Q23, Q24, Q25 (
unmodifiableList,IteratorvsListIterator).
🟡 Middle Level Track (Internals & Complexities)
- Big-O & Algorithmic Limits: Q5, Q6 (
ArrayListamortized array growth vsLinkedListtraversal). - Hash & Tree Mechanics: Q12, Q17 (
HashSetbacked byHashMap,WeakHashMapreference purging). - Thread Safety: Q21, Q22 (Synchronized wrappers, lock contention).
- Mutation Pitfalls: Q26, Q27, Q28 (
modCount,ConcurrentModificationException,removeIf). - Sorting & Contracts: Q29 (
Comparable.compareTovsComparator.compare, Timsort stability).
🔴 Senior Level Track (Performance, Low Latency & Concurrency)
- Hardware Cache Locality & SIMD: Q5, Q6 (
System.arraycopyintrinsics, CPU L1/L2 cache prefetching vs pointer chasing). - Lock-Free Concurrency & CAS: Q18, Q19 (
ConcurrentHashMaptable CAS, bucket synchronization,CounterCells/LongAdder). - Copy-on-Write Memory Models: Q20 (
CopyOnWriteArrayListvolatile arrays, eventual consistency). - Modern Java Innovations: Java 21
SequencedCollection(SequencedSet,SequencedMap) and unmodifiable collections (List.of(),Set.of()).