Java Collections: Basics and Usage
A beginner's quiz on the fundamentals of Java Collections.
Questions in this quiz
15 questions on Java Collections: Basics and Usage. Work through them here, then start the quiz to answer them and see your score.
1.Which interface does the ArrayList class implement?
- AQueue
- BSet
- CMap
- DList
2.What is the default initial capacity of an ArrayList in Java?
- A10
- B15
- C20
- D5
3.Which of the following is NOT a part of the Java Collections Framework?
- ALinkedList
- BHashMap
- CArray
- DTreeSet
4.Which method is used to add an element to a List in Java?
- Ainsert()
- Bput()
- Cadd()
- Dappend()
5.What does the 'Set' interface guarantee?
- ANo duplicate elements
- BFixed size
- CFast access
- DOrder of elements
6.Which collection class allows you to access elements by a key?
- ALinkedList
- BArrayList
- CHashMap
- DTreeSet
7.Which of these classes implements the Queue interface?
- AArrayList
- BHashMap
- CPriorityQueue
- DHashSet
8.Which method is used to remove all elements from a Collection?
- Aclear()
- BremoveAll()
- Cempty()
- DdeleteAll()
9.Which of the following is a legacy class that is synchronized?
- ALinkedList
- BVector
- CArrayList
- DHashSet
10.What is the time complexity of accessing an element in an ArrayList by index?
- AO(n^2)
- BO(log n)
- CO(n)
- DO(1)
11.Which collection is best suited for storing unique elements in sorted order?
- AArrayList
- BTreeSet
- CHashSet
- DLinkedList
12.Which of the following is true about LinkedList?
- AIt does not allow null elements
- BIt is synchronized
- CIt implements the List interface only
- DIt allows duplicate elements
13.Which method returns the number of elements in a Collection?
- Acount()
- Bsize()
- Clength()
- DgetSize()
14.What is the main characteristic of a Map in Java?
- AAllows duplicate keys
- BStores elements in a sorted order
- CStores key-value pairs
- DDoes not allow null keys
15.Which method is used to check if a Collection is empty?
- AisNull()
- BisEmpty()
- ChasNoElements()
- DisBlank()