Single Choice Easy

QWhat are the differences between HashMap and HashTable in Java?

ID: #10346 Class and Object Concept in Java 191 views
Question Info
#10346Q ID
EasyDifficulty
Class and Object Concept in JavaTopic

Choose the Best Option

Click any option to instantly check if you're correct.

  • A HashMap allows null values and is not synchronized, while HashTable does not allow null values and is synchronized.
  • B HashTable allows null values and is not synchronized, while HashMap does not allow null values and is synchronized.
  • C Both HashMap and HashTable allow null values, but HashMap is not synchronized while HashTable is synchronized.
  • D Both HashMap and HashTable do not allow null values, but HashMap is synchronized while HashTable is not synchronized.
Correct Answer

Explanation

The main difference between HashMap and HashTable is that HashMap allows null values while HashTable does not. Additionally, HashMap is not synchronized, meaning that multiple threads can access it simultaneously, while HashTable is synchronized, meaning that only one thread can access it at a time.

No Previous No Next

Share This Question

Challenge a friend or share with your study group.