CodeStudy.net
Toggle Menu
Home
Online Java Compiler
Tutorials
Java Tutorial
Python Tutorial
SQL Database Design
Blog
All Posts
Java Collections Framework
Review your understanding of Lists,Sets,Maps,and their implementations.
1. Which interface in the Java Collections Framework allows duplicate elements and maintains insertion order?
List
Set
Map
Queue
2. Which class is a resizable array implementation of the List interface?
ArrayList
LinkedList
HashSet
TreeMap
3. HashSet does not allow duplicate elements.
True
False
4. Which of the following are implementations of the Set interface?
HashSet
TreeSet
ArrayList
LinkedList
LinkedHashSet
5. What is the root interface of the Java Collections Framework (excluding Map interfaces)?
6. Which collection does NOT allow null elements?
HashSet
TreeSet
ArrayList
LinkedList
7. LinkedList provides faster insertion at the middle compared to ArrayList.
True
False
8. Which of the following collections are sorted by default?
TreeSet
HashSet
TreeMap
HashMap
LinkedHashMap
9. What is the initial capacity of an ArrayList when created with the default constructor?
0
10
16
20
10. HashMap is synchronized (thread-safe) by default.
True
False
11. What method is used to add an element to the end of a List?
12. Which of the following statements about ArrayList and LinkedList are true?
ArrayList is better for random access
LinkedList is better for frequent insertions at the ends
ArrayList uses less memory than LinkedList
LinkedList implements the Deque interface
13. Which Map implementation maintains entries in insertion order?
HashMap
TreeMap
LinkedHashMap
Hashtable
14. The List interface provides a method to retrieve an element by index.
True
False
15. What is the interface that represents a collection of key-value pairs?
16. Which of the following methods are part of the Collection interface?
add(E e)
get(int index)
size()
remove(Object o)
put(K key, V value)
17. Which interface represents an ordered collection that does not allow duplicate elements?
List
Set
SortedSet
Queue
18. Vector is a legacy class and is thread-safe.
True
False
19. What method is used to obtain an iterator over a Collection?
20. Which of the following are immutable collections?
Collections.unmodifiableList(new ArrayList<>())
new ArrayList<>()
Arrays.asList("a", "b")
Collections.emptySet()
Reset
Answered 0 of 0 — 0 correct