CHAPTER 20
Beginner
Collections Framework
Updated: May 17, 2026
5 min read
# CHAPTER 20
Collections Framework
1. Introduction
Arrays are fixed-size. The Collections Framework provides dynamic, resizable data structures — lists, sets, maps, and queues. It is the most used part of the Java Standard Library in enterprise applications.2. Collections Hierarchy
3. ArrayList
Dynamic array that grows automatically:
java
4. LinkedList
Doubly-linked list — efficient for insertions/deletions:
java
5. HashMap
Key-value pairs with O(1) average lookup:
java
6. HashSet
Unique elements, no duplicates:
java
7. Iterator
java
8. Collections Utility Class
java
9. Mini Project: Contact Manager
java
10. MCQ Quiz with Answers
Question 1
ArrayList vs Array?
Question 2
HashMap stores:
Question 3
HashSet allows duplicates?
Question 4
Which has fastest lookup?
Question 5
Collections.sort() sorts:
Question 6
LinkedList is best for:
Question 7
TreeSet stores elements:
Question 8
Which interface do all collections extend?
Question 9
HashMap allows null keys?
Question 10
list.size() returns:
11. Interview Questions
- Q: ArrayList vs LinkedList — when to use each?
- Q: HashMap vs TreeMap vs LinkedHashMap?
- Q: How does HashMap work internally? (Hashing, buckets)
-
Q: What is the difference between
fail-fastandfail-safeiterators?