What is the purpose of the Java Collections Framework?
A. To provide a unified architecture for representing and manipulating collections
B. To provide a way to create arrays
C. To define primitive data types
D. To handle exceptions
Select an option to see the answer and solution.
Which interface in the Java Collections Framework represents an ordered collection of elements that can contain duplicate values?
A. `Collection`
B. `Map`
C. `Set`
D. `List`
Select an option to see the answer and solution.
What is the primary difference between a `List` and a `Set` in the Java Collections Framework?
A. A `Set` allows duplicate elements, while a `List` does not
B. A `List` is unmodifiable, while a `Set` is modifiable
C. A `List` allows duplicate elements, while a `Set` does not
D. A `Set` is indexed, while a `List` is not
Select an option to see the answer and solution.
Which class is typically used to implement a `List` in the Java Collections Framework?
A. `HashMap`
B. `ArrayList`
C. `LinkedList`
D. None of These
Select an option to see the answer and solution.
In the Java Collections Framework, which interface extends the `List` interface to provide more efficient insertions and deletions in the middle of the list?
A. `Map`
B. `Set`
C. `Deque`
D. `Queue`
Select an option to see the answer and solution.
What is the purpose of the `Map` interface in the Java Collections Framework?
A. To store a collection of objects
B. To provide a stack data structure
C. To store unique elements
D. To store key-value pairs
Select an option to see the answer and solution.
Which class is typically used to implement a `Map` in the Java Collections Framework?
A. `HashMap`
B. `ArrayList`
C. `HashSet`
D. `LinkedList`
Select an option to see the answer and solution.
What is the primary difference between a `HashMap` and a `TreeMap` in the Java Collections Framework?
A. A `TreeMap` uses a linked list to store elements
B. A `HashMap` is synchronized, while a `TreeMap` is not
C. A `TreeMap` allows duplicate keys, while a `HashMap` does not
D. A `HashMap` does not maintain order, while a `TreeMap` does
Select an option to see the answer and solution.
In the Java Collections Framework, which interface represents a collection of unique elements with no duplicates?
A. `List`
B. `Map`
C. `Set`
D. `Collection`
Select an option to see the answer and solution.
Which class is typically used to implement a `Set` in the Java Collections Framework?
A. `HashMap`
B. `HashSet`
C. `LinkedList`
D. None of These
Select an option to see the answer and solution.
What is the primary difference between a `HashSet` and a `LinkedHashSet` in the Java Collections Framework?
A. A `HashSet` uses a tree structure to store elements
B. A `LinkedHashSet` is synchronized, while a `HashSet` is not
C. A `LinkedHashSet` maintains insertion order, while a `HashSet` does not
D. A `HashSet` allows duplicate elements, while a `LinkedHashSet` does not
Select an option to see the answer and solution.
Which interface in the Java Collections Framework represents a collection of elements with no specific order?
A. `List`
B. `Map`
C. `Collection`
D. `Set`
Select an option to see the answer and solution.
What is the primary difference between a `Queue` and a `Deque` in the Java Collections Framework?
A. A `Queue` represents a single-ended queue, while a `Deque` represents a double-ended queue
B. A `Queue` allows duplicate elements, while a `Deque` does not
C. A `Deque` is synchronized, while a `Queue` is not
D. A `Queue` is indexed, while a `Deque` is not
Select an option to see the answer and solution.
Which class is typically used to implement a `Deque` in the Java Collections Framework?
A. `LinkedList`
B. `HashMap`
C. `HashSet`
D. `ArrayDeque`
Select an option to see the answer and solution.
In the Java Collections Framework, which class allows you to create a synchronized (thread-safe) collection?
A. `ArrayList`
B. `HashMap`
C. `Collections`
D. `HashSet`
Select an option to see the answer and solution.
Which interface in the Java Collections Framework extends the `Set` interface and represents a collection of elements stored in a sorted order?
A. `Map`
B. `SortedSet`
C. `Queue`
D. None of These
Select an option to see the answer and solution.
What is the purpose of the `Comparator` interface in Java Collections Framework?
A. It represents a generic collection
B. It provides methods for hashing elements
C. It defines a comparison function for ordering elements
D. It represents a synchronized collection
Select an option to see the answer and solution.
Which class is typically used to implement a `SortedSet` in the Java Collections Framework?
A. `HashSet`
B. `LinkedHashSet`
C. `ArrayList`
D. `TreeSet`
Select an option to see the answer and solution.
In the Java Collections Framework, which interface represents a last-in, first-out (LIFO) stack of elements?
A. `Stack`
B. `Queue`
C. `List`
D. `Deque`
Select an option to see the answer and solution.
What is the primary difference between a `Stack` and a `Queue` in the Java Collections Framework?
A. A `Queue` allows duplicate elements, while a `Stack` does not
B. A `Stack` allows duplicate elements, while a `Queue` does not
C. A `Queue` uses a LIFO order, while a `Stack` uses a FIFO order
D. A `Stack` uses a LIFO (Last-In-First-Out) order, while a `Queue` uses a FIFO (First-In-First-Out) order
Select an option to see the answer and solution.