Search Interview Questions
| 2355 questions in repository.|
There are more than 200 unanswered questions.
Click here and help us by providing the answer.
Have a video suggestion.
Click Correct / Improve and please let us know.
|Java - Interview Questions and Answers|
|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
|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 ?|