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

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

Mastering Java: The Ultimate Quiz for 'Thinking in Java'. Dive deep into Java with multiple-choice questions. Challenge yourself with quiz questions designed to test and improve your understanding of the 'Thinking in Java' book. Get ready for your exam!

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.