Java - Why HashTable has been deprecated ?
Javasearch.buggybread.com
Share

Search Java Interview Questions


 2098 questions in repository.
 There are more than 200 unanswered questions.
Click here and help us by providing the answer.
Label / Company      Label / Company / Text

   



Java - Interview Questions and Answers

 Q1. Why HashTable has been deprecated ?Core Java2016-07-08 10:01:58

Ans. HashTable has been Deprecated as an alternative ConcurrentHashMap has been provided which uses multiple buckets to store data and hence much better performance than hashtable. Moreover there is already a raw type hashmap. The only difference between the HashTable and HashMap is that Hashtable is synchronized whereas HashMap is not. Most of the synchronized collections have been deprecated and their raw alternative have been presented as preferred.

Synchronization has a cost. Using synchronized collection at a place where there is hardly any need of it would means useless utilization of resources. As these collections are rarely used in static context or shared among threads, Java might have thought it better to just provide the raw collection and let developer implement synchronization if he feels the need to do so.

As HashMap has been presented as default and preferred way of using Map with read optimized hashing, and ConcurrentHashMap has been provided for synchronized access which provides better performance than HashTable, Java thought it right to deprecate the use of HashTable.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     hashtable  synchronized collections  Why synchronized collections have been deprecated  Why HashTable has been deprecated  HashTable vs HashMap      expert

Try 3 Question(s) Test


Related Questions

  Difference between HashMap and Hashtable?
  Can we use null as a key for a map collection ?
  What is a Property class ?
  Can we add duplicate keys in a HashMap ? What will happen if we attempt to add duplicate values ?
  Which interface does java.util.Hashtable implement?
  Which interface does java.util.Hashtable implement ?
  Which of the following is false ?
  Which of the collections allows null as the key ?
 Difference between concurrentHashMap and HashTable ?




Subscribe to Java News and Posts. Get latest updates and posts on Java from Buggybread.com
Enter your email address:
Delivered by FeedBurner



comments powered by Disqus
 

Help us and Others Improve. Please let us know the questions asked in any of your previous interview.

Any input from you will be highly appreciated and It will unlock the application for 10 more requests.

Company Name:
Questions Asked:
         

X Close this

X Close this

Help Us Improve.
Please share your
interview experience.

Company Name:   


Questions Asked: