The Java Collections Framework provides a unified architecture consisting of interfaces (such as List, Set, and Map) and implementation classes (like ArrayList and HashMap) to store and manipulate object groups efficiently. It standardizes data structures, reducing programming effort while enhancing performance through optimized algorithms. Key interfaces include Collection and Map, which support specialized operations like sorting, searching, and hashing. Understanding internal complexities and behavioral differences between interfaces is vital for writing scalable code and clearing technical interviews.
Java Collections Frame Work MCQs
1 min read
Correct Answer: a) Collection
Explanation:
The Collection interface is the root of the collection hierarchy, though it extends Iterable.
Correct Answer: d) None of the above
Explanation:
The Map interface does not extend the Collection interface.
Correct Answer: b) ArrayList
Explanation:
ArrayList is a resizable-array implementation of the List interface.
Correct Answer: b) 10
Explanation:
The default initial capacity of an ArrayList is 10.
Correct Answer: c) Set
Explanation:
A Set is a collection that contains no duplicate elements.
Correct Answer: b) LinkedList
Explanation:
LinkedList implements both the List and Deque interfaces and is internally backed by a doubly linked list.
Correct Answer: c) Queue
Explanation:
The Queue interface represents a collection designed for holding elements prior to processing in a FIFO manner.
Correct Answer: b) Vector
Explanation:
Vector is a legacy class from Java 1.0 and is synchronized.
Correct Answer: c) The new value replaces the old value
Explanation:
If a duplicate key is added, the HashMap replaces the old value associated with the key with the new value.
Correct Answer: c) HashSet
Explanation:
HashSet offers constant time performance for basic operations, provided the hash function disperses elements properly.
Correct Answer: c) LinkedHashMap
Explanation:
LinkedHashMap uses a doubly-linked list running through all its entries to maintain insertion order.
Correct Answer: b) TreeMap
Explanation:
TreeMap is a Red-Black tree based NavigableMap implementation that sorts its keys.
Correct Answer: b) 1
Explanation:
HashMap permits exactly one null key and multiple null values.
Correct Answer: a) 0
Explanation:
TreeMap using natural ordering throws a NullPointerException if you attempt to add a null key.
Correct Answer: b) ListIterator
Explanation:
ListIterator allows traversing a list in both directions and modifying it during iteration.
Correct Answer: b) ConcurrentModificationException
Explanation:
Fail-fast iterators throw ConcurrentModificationException if modified structurally during iteration.
Correct Answer: c) Stack
Explanation:
The Stack class represents a last-in-first-out (LIFO) stack of objects and extends Vector.
Correct Answer: a) parallelStream()
Explanation:
The parallelStream() method returns a possibly parallel Stream with the collection as its source.
Correct Answer: c) O(1)
Explanation:
ArrayList provides constant time O(1) performance for retrieving an element using its index.
Correct Answer: b) O(n)
Explanation:
Retrieving an element by index in a LinkedList takes O(n) time as it must traverse the list.
Correct Answer: b) TreeSet
Explanation:
TreeSet and TreeMap are implemented using a Red-Black tree structure to keep elements sorted.
Correct Answer: b) Comparable
Explanation:
The Comparable interface compareTo() method defines the natural ordering of objects.
Correct Answer: b) Comparator
Explanation:
The Comparator interface compare() method defines a custom external ordering.
Correct Answer: c) ConcurrentHashMap
Explanation:
ConcurrentHashMap allows concurrent read and update operations without locking the entire map.
Correct Answer: c) Deque
Explanation:
Deque (Double Ended Queue) supports insertion, removal, and retrieval of elements at both ends.
Correct Answer: b) Returns the head without removing it
Explanation:
peek() retrieves, but does not remove, the head of the queue. It returns null if empty.
Correct Answer: b) poll() returns null if empty; remove() throws an exception
Explanation:
Both remove and return the head, but remove() throws NoSuchElementException when empty.
Correct Answer: b) The threshold at which the map is resized
Explanation:
The load factor determines when the hash table is resized. The default is 0.75.
Correct Answer: b) 16
Explanation:
The default initial capacity of a HashMap is 16.
Correct Answer: c) Properties
Explanation:
Properties extends Hashtable, which implements Map, not Collection.
Correct Answer: c) List
Explanation:
List is an ordered collection where elements can be accessed using a zero-based index.
Correct Answer: c) Creates a larger array and copies the elements
Explanation:
ArrayList resizes itself dynamically by typically increasing its capacity by 50% when full.
Correct Answer: c) LinkedList
Explanation:
LinkedList provides O(1) time complexity for insertions and deletions once the location is found.
Correct Answer: c) Hashtable
Explanation:
Hashtable is a synchronized legacy class that implements the Map interface.
Correct Answer: d) No, neither can be null
Explanation:
Unlike HashMap, Hashtable does not permit null keys or null values.
Correct Answer: c) get()
Explanation:
The get() method belongs to the List interface, not the generic Collection interface.
Correct Answer: a) O(1)
Explanation:
HashSet operations like add, remove, and contains generally take O(1) time.
Correct Answer: b) Collections.sort()
Explanation:
The java.util.Collections.sort() method is used to sort Lists.
Correct Answer: b) Collections.synchronizedList(new ArrayList<>())
Explanation:
The Collections utility class provides methods to create thread-safe wrappers for collections.
Correct Answer: d) IdentityHashMap
Explanation:
IdentityHashMap uses reference equality (==) instead of object equality to compare keys.
Correct Answer: b) PriorityQueue
Explanation:
PriorityQueue is an unbounded priority queue based on a priority heap.
Correct Answer: c) ArrayDeque
Explanation:
ArrayDeque is a resizable-array implementation of the Deque interface.
Correct Answer: b) ArrayDeque
Explanation:
ArrayDeque is faster than Stack because it is not synchronized.
Correct Answer: a) Queue
Explanation:
PriorityQueue implements the Queue interface.
Correct Answer: b) UnsupportedOperationException
Explanation:
Attempting to modify an unmodifiable collection results in an UnsupportedOperationException.
Correct Answer: b) Retains only the elements that are in the specified collection
Explanation:
retainAll() removes elements not contained in the specified collection (Intersection).
Correct Answer: b) remove()
Explanation:
The Iterator.remove() method safely removes the last element returned by the iterator.
Correct Answer: b) Collections.reverse()
Explanation:
Collections.reverse() reverses the order of the elements in the specified list.
Correct Answer: b) CopyOnWriteArrayList
Explanation:
CopyOnWriteArrayList creates a fresh copy of the underlying array upon every mutative operation.
Correct Answer: b) When there are frequent reads and few writes
Explanation:
Because writes copy the entire array, it is only efficient when reads vastly outnumber writes.
Correct Answer: b) LinkedHashMap
Explanation:
By overriding removeEldestEntry(), LinkedHashMap can act as an LRU cache.
Correct Answer: c) WeakHashMap
Explanation:
WeakHashMap keys are weakly referenced and can be garbage collected if no other strong references exist.
Correct Answer: b) Collections.max()
Explanation:
Collections.max() returns the maximum element of the given collection.
Correct Answer: d) Set<Map.Entry<K,V>>
Explanation:
entrySet() returns a Set view of the map's key-value entries.
Correct Answer: b) A Set of keys
Explanation:
keySet() returns a Set view of the keys contained in the map, because keys must be unique.
Correct Answer: c) A Collection of values
Explanation:
values() returns a Collection view of the values in the map, as values can be duplicated.
Correct Answer: b) computeIfAbsent()
Explanation:
computeIfAbsent() computes a new value for the specified key if it is not already associated with a value.
Correct Answer: a) No specific interface, it returns a generic type
Explanation:
Iterator's next() method returns an element of the generic type E.
Correct Answer: b) NavigableSet
Explanation:
NavigableSet extends SortedSet to report closest matches for given search targets.
Correct Answer: c) A collision occurs and elements are chained
Explanation:
HashMap handles collisions by chaining elements in a linked list or a balanced tree.
Correct Answer: b) 8
Explanation:
The TREEIFY_THRESHOLD is 8, meaning a bin turns into a tree structure at 8 elements.
Correct Answer: c) HashMap
Explanation:
HashSet uses an instance of HashMap internally, where elements act as keys.
Correct Answer: b) EnumMap
Explanation:
EnumMap is a specialized Map implementation for use with enum type keys.
Correct Answer: a) EnumSet
Explanation:
EnumSet is a specialized Set implementation for enum types, represented as bit vectors.
Correct Answer: b) Arrays.asList()
Explanation:
Arrays.asList() returns a fixed-size list backed by the specified array.
Correct Answer: b) UnsupportedOperationException
Explanation:
The list returned by Arrays.asList() is fixed-size. Structural modifications throw UnsupportedOperationException.
Correct Answer: c) List.of()
Explanation:
Java 9 introduced List.of() to create unmodifiable lists easily.
Correct Answer: a) 0
Explanation:
Factory methods like Set.of() do not allow null elements and throw NullPointerException.
Correct Answer: b) forEachRemaining()
Explanation:
Iterator.forEachRemaining() performs the given action for each remaining element.
Correct Answer: d) Spliterator
Explanation:
Spliterator is an interface introduced in Java 8 to support parallel traversal.
Correct Answer: c) spliterator()
Explanation:
The spliterator() method returns a Spliterator over the elements in the collection.
Correct Answer: c) To wait for space or elements to become available
Explanation:
BlockingQueue supports operations that wait for the queue to become non-empty or for space.
Correct Answer: b) ArrayBlockingQueue
Explanation:
ArrayBlockingQueue is a bounded blocking queue backed by an array.
Correct Answer: c) ArrayList
Explanation:
ArrayList is not thread-safe and its fail-fast iterators throw ConcurrentModificationException.
Correct Answer: c) It replaces and returns the old value
Explanation:
The put() method replaces the existing value for the key and returns the previous value.
Correct Answer: b) clear()
Explanation:
The clear() method removes all elements from the collection.
Correct Answer: b) removeAll() takes a collection of elements; clear() removes everything
Explanation:
removeAll(Collection) removes only the elements present in the specified collection, clear() empties it.
Correct Answer: c) Collections.shuffle(list)
Explanation:
Collections.shuffle() randomly permutes the specified list.
Correct Answer: c) ConcurrentSkipListMap
Explanation:
ConcurrentSkipListMap provides a thread-safe, scalable concurrent implementation of NavigableMap.
Correct Answer: b) Comparable
Explanation:
If no Comparator is provided, the elements must implement Comparable.
Correct Answer: c) O(n)
Explanation:
ArrayList must perform a linear search, which takes O(n) time.
Correct Answer: b) Hashtable
Explanation:
Properties extends Hashtable to maintain a list of string key-value pairs.
Correct Answer: a) Vector
Explanation:
Vector is synchronized by default, making it thread-safe but slower than ArrayList.
Correct Answer: c) It throws ConcurrentModificationException
Explanation:
An enhanced for-loop uses an Iterator internally, which is fail-fast.
Correct Answer: b) It is not part of the Collection framework interface hierarchy
Explanation:
BitSet is a utility class for bit arrays but does not implement Collection or Set.
Correct Answer: d) There is no built-in primitive collection in java.util
Explanation:
The standard java.util package does not provide primitive specialization collections.
Correct Answer: b) Returns an Object array containing all elements
Explanation:
Collection.toArray() converts the collection into a standard array of Objects.
Correct Answer: a) Fills the provided array or creates a new one of the same type
Explanation:
It returns an array containing all of the elements with the runtime type of the specified array.
Correct Answer: b) No
Explanation:
ArrayDeque does not permit null elements.
Correct Answer: b) No
Explanation:
PriorityQueue does not permit null elements because they cannot be compared.
Correct Answer: b) Collections.emptyList()
Explanation:
Collections.emptyList() returns a static, immutable empty list.
Correct Answer: a) Collections.singletonList(element)
Explanation:
Collections.singletonList() creates an immutable list containing only the specified object.
Correct Answer: b) To calculate the index of the bucket
Explanation:
The hash function processes the key to determine the bucket index.
Correct Answer: d) Maps guarantee key uniqueness, not elements (values)
Explanation:
Map ensures keys are unique, but it does not restrict duplicate values.
Correct Answer: b) It throws IndexOutOfBoundsException
Explanation:
You cannot insert at an index strictly greater than the current size of the ArrayList.
Correct Answer: b) Arrays.asList(arr)
Explanation:
Arrays.asList() provides a bridge between array-based and collection-based APIs.
Correct Answer: a) Comparable defines natural ordering; Comparator defines custom ordering
Explanation:
Comparable is for default sorting, Comparator lets you define multiple external sorting strategies.
Correct Answer: a) ArrayList
Explanation:
ArrayList has contiguous memory allocation, making CPU cache access much faster for iteration.
Correct Answer: b) Returns true if the two collections have no elements in common
Explanation:
Collections.disjoint returns true if the two specified collections have no elements in common.
Correct Answer: a) It extends Vector
Explanation:
Stack is a class that extends Vector to provide LIFO operations.
Correct Answer: a) To reduce the capacity of the instance to its current size
Explanation:
trimToSize() trims the capacity of the ArrayList to its current size to minimize storage.
Correct Answer: c) Predicate
Explanation:
removeIf(Predicate filter) removes all elements that satisfy the given predicate.
Correct Answer: b) List.replaceAll()
Explanation:
replaceAll() replaces each element with the result of applying an operator to that element.
Correct Answer: a) ConcurrentHashMap
Explanation:
ConcurrentHashMap allows lock-free read operations while being thread-safe.
Correct Answer: b) If key absent, puts value; if present, uses a function to merge values
Explanation:
Map.merge() updates the value using the provided function to merge the existing and new values.
Correct Answer: b) No, you must use their wrapper classes
Explanation:
Java Collections can only hold object references. Primitives are autoboxed into their wrapper classes.
Correct Answer: c) Queue
Explanation:
The Queue interface defines offer, poll, and peek for working with elements safely.
Correct Answer: c) A negative integer representing the insertion point
Explanation:
It returns a negative value that indicates the exact insertion point where the element should go.
Correct Answer: c) It must be sorted in ascending order prior to the call
Explanation:
binarySearch() only works reliably if the list has already been sorted.
Correct Answer: c) CopyOnWriteArrayList
Explanation:
CopyOnWriteArrayList iterators rely on a snapshot of the array and will not throw ConcurrentModificationException.
Correct Answer: b) Returns the mapped value, or defaultValue if the map contains no mapping
Explanation:
It provides a safe way to fetch a value with a fallback, without modifying the map.
Related Posts

Latest Java OOP MCQs
Object-Oriented Programming (OOP) is the core paradigm underlying Java, designed to organize software design around data, or objects, rather than…
October 19, 2026By MCQs Generator
No Image
400+ C++ Interview Questions MCQ
1. Which of these interfaces is the root of the collection hierarchy? a) Collection b) List c) Root d) Iterable…
October 19, 2026By MCQs Generator

JavaScript DOM Manipulation MCQs
The Document Object Model (DOM) is a cross-platform programming interface that treats HTML and XML documents as a hierarchical tree…
August 29, 2026By MCQs Generator
Related Categories

AI & Data Science MCQ
5 topics
By MCQs Generator

Arts & Humanities MCQ
4 topics
By MCQs Generator

Civil Engineering MCQ
4 topics
By MCQs Generator

Commerce & Business MCQ
4 topics
By MCQs Generator

Competitive Exams MCQ
5 topics
By MCQs Generator

Electrical & Electronics Engineering MCQ
3 topics
By MCQs Generator

General Knowledge MCQ
2 topics
By MCQs Generator

General Science MCQ
4 topics
By MCQs Generator

Law & Judiciary MCQ
3 topics
By MCQs Generator

Mechanical Engineering MCQ
4 topics
By MCQs Generator

Medical & Health Sciences MCQ
4 topics
By MCQs Generator

Modern Tech Fields MCQ
3 topics
By MCQs Generator