Quizzes Index
In his book Java Collections, John Zukowski explained the Collections Libraries. Now, show what you know!
1. Which of the following is not in the same class hierarchy?
Map
List
Collection
Set
2. The Hashtable class has been retrofitted into the Collections Framework. Which of the following interfaces does it implement?
Hashtable
SortedMap
3. Which method doesn't belong with the respective interface?
Comparable
compareTo()
Comparator
equals()
ListIterator
getPrevious()
Iterator
remove()
4. If you had an array of the following type stored in the variable theArray, which cannot be sorted with Arrays.sort(theArray)?
theArray
Arrays.sort(theArray)
String
int
BigDecimal
URL
5. If you try to add an element to a list after calling the unmodifiableList() method of Collections, which exception will be thrown?
unmodifiableList()
Collections
UnsupportedOperationException
NotSupportedException
OperationNotSupportedException
OperationalException
6. True or False. WeakHashMap is a subclass of HashMap.
WeakHashMap
HashMap
7. Which of the following is true about HashMap and Hashtable?
8. Which of the following variable types cannot be used as an index for an array?
byte
long
char
9. If you want to create a custom Set by subclassing the AbstractSet class, which methods must you implement?
AbstractSet
add()
iterator()
size()
hashCode()
10. True or False. The StringTokenizer class implements the Enumeration interface. With the 1.2 release of the J2SE, it was modified to also implement the Iterator interface.
StringTokenizer
Enumeration