Java Collections Framework Quiz

Test your knowledge of Java collections including Map, Set, List, ArrayList, Hashtable, LinkedHashMap, and object equality methods.

8 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

Suppose that you would like to create an instance of a new Map that has an iteration order that is the same as the iteration order of an existing instance of a Map. Which concrete implementation of the Map interface should be used for the new instance?

  1. TreeMap
  2. HashMap
  3. LinkedHashMap
  4. The answer depends on the implementation of the existing instance.
Question 2 Multiple Choice (Single Answer)

Which class does not override the equals() and hashCode() methods, inheriting them directly from class Object?

  1. java.lang.String
  2. java.lang.Double
  3. java.lang.StringBuffer
  4. java.lang.Character
Question 3 Multiple Choice (Single Answer)

Which collection class allows you to grow or shrink its size and provides indexed access to its elements, but whose methods are not synchronized?

  1. java.util.HashSet
  2. java.util.LinkedHashSet
  3. java.util.List
  4. java.util.ArrayList
Question 4 Multiple Choice (Single Answer)

You need to store elements in a collection that guarantees that no duplicates are stored and all elements can be accessed in natural order. Which interface provides that capability?

  1. java.util.Map
  2. java.util.Set
  3. java.util.List
  4. java.util.Collection
Question 5 Multiple Choice (Single Answer)

Which interface does java.util.Hashtable implement?

  1. Java.util.Map
  2. Java.util.List
  3. Java.util.HashTable
  4. Java.util.Collection
Question 6 Multiple Choice (Single Answer)

Which interface provides the capability to store objects using a key-value pair?

  1. Java.util.Map
  2. Java.util.Set
  3. Java.util.List
  4. Java.util.Collection
Question 7 Multiple Choice (Single Answer)

Which collection class allows you to associate its elements with key values, and allows you to retrieve objects in FIFO (first-in, first-out) sequence?

  1. java.util.ArrayList
  2. java.util.LinkedHashMap
  3. java.util.HashMap
  4. java.util.TreeMap
Question 8 Multiple Choice (Single Answer)

Which collection class allows you to access its elements by associating a key with an element's value, and provides synchronization?

  1. java.util.SortedMap
  2. java.util.TreeMap
  3. java.util.TreeSet
  4. java.util.Hashtable