Mastering Java: The Ultimate Quiz for 'Thinking in Java'

Disable ads (and more) with a membership for a one time $2.99 payment

Dive into the depths of Java with our quiz based on "Thinking in Java, Fourth Edition" by Bruce Eckel. Test your knowledge, solidify concepts, and prepare for certification with challenging questions and insightful feedback.

Each practice test/flash card set has 50 randomly selected questions from a bank of over 500. You'll get a new set of questions each time!

Practice this question and more.


What is used as a replacement for Hashtable in modern Java container library?

  1. ArrayList

  2. Vector

  3. HashMap

  4. List

The correct answer is: HashMap

The modern Java container library often uses the HashMap class as a replacement for the outdated Hashtable class. Unlike the Hashtable class, HashMap is not synchronized which makes it more efficient. Additionally, HashMaps allow for null values and keys, while Hashtables do not. ArrayList, Vector, and List are all different data structures that are not replacements for Hashtable in the modern Java container library. They each have their own specific use cases and cannot be used interchangeably with Hashtable. Therefore, the correct answer is C HashMap.