Core Java - Interview Questions and Answers for 'Hashtable' | Search Java Interview Question - javasearch.buggybread.com
Javasearch.buggybread.com
Share

Search Interview Questions


 2802 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.
Label / Company      Label / Company / Text

   



Core Java - Interview Questions and Answers for 'Hashtable' - 16 question(s) found - Order By Newest

Very frequently asked across all types of companies.
  Q1. Difference between HashMap and Hashtable?Core Java
Anonymous
Ans. Hashtable is synchronized whereas HashMap is not.HashMap allows null values whereas Hashtable doesnt allow null values.

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

   Like      Discuss      Correct / Improve     java   collections   hashmap   map   hashtable   basic interview question   ebay   tcs    hcl technologies   infosys technologies     Morgan Stanley  Yahoo  Q3 Technologies  PriceLine  Solution Rally  Coupang  HCL Technologies  Tata Consultancy (TCS)   Infosys Technologies  Accenture India  JPMorgan Chase  Priceline.com      basic        frequent

Try 2 Question(s) Test


Frequently asked in all types of companies especially Indian Services companies. Frequently asked in CTS (Based on 2 feedback)
 Q2. What is the use of hashcode in Java ?Core Java
Anonymous
Ans. Hashcode is used for bucketing in Hash implementations like HashMap, HashTable, HashSet etc. The value received from hashcode() is used as bucket number for storing elements. This bucket number is the address of the element inside the set/map. when you do contains() then it will take the hashcode of the element, then look for the bucket where hashcode points to and if more than 1 element is found in the same bucket (multiple objects can have the same hashcode) then it uses the equals() method to evaluate if object are equal, and then decide if contain() is true or false, or decide if element could be added in the set or not.

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


   Like      Discuss      Correct / Improve     java   collections   hashcode   advanced  hashtable     Cognizant (CTS)  Compro Technologies  VigLink  Proofpoint  Accolite      intermediate        frequent

Try 1 Question(s) Test


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

Ans. HashTable has been deprecated. As an alternative, ConcurrentHashMap has been provided. It 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 in places where there is no need of it leads to useless utilization of resources. As these collections are rarely used in a static context or shared among threads, Java might have thought it better to just provide the raw collection and let developers implement synchronization if he feels the need to do so. HashMap is now presented as the default and the preferred way of using Map with read optimized hashing, and ConcurrentHashMap has been provided for synchronized access which provides better performance than HashTable. Because of this, Java thought it right to deprecate the use of HashTable.'

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


 Q4. Can we use null as a key for a map collection ?Core Java
Anonymous
Ans. Yes , for HashMap. HashMap implements Map interface. HashMap allows one null key and any number of null values.

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

   Like      Discuss      Correct / Improve     java   collections   hashmap   map   hashtable   yes-no     BlackBerry


 Q5. What is a Property class ?Core Java
Anonymous
Ans. The properties class is a subclass of Hashtable that can be read from or written to a stream.

  Sample Code for Load Properties using Property Class

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

   Like      Discuss      Correct / Improve     java   collections   hashtable   map   synchronization   synchronized


 Q6. Can we add duplicate keys in a HashMap ? What will happen if we attempt to add duplicate values ?
Admin
info@buggybread.com
Ans. No, We cannot have duplicate keys in HashMap. If we attempt to do so , the previous value for the key is overwritten.

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

   Like      Discuss      Correct / Improve     java   collections   hashmap   map   hashtable

Try 1 Question(s) Test


 Q7. Which interface does java.util.Hashtable implement?Core Java
Anonymous
Ans. Java.util.Map

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

   Like      Discuss      Correct / Improve     java   collections   hashtable   map      basic        rare


  Q8. What is the use of HashCode in objects ?Core Java
Admin
info@buggybread.com
Ans. Hashcode is used for bucketing in Hash implementations like HashMap, HashTable, HashSet etc.

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

   Like      Discuss      Correct / Improve     java   string   hashcode   hash code   string comparison  hashtable     Verilogue  Deutche bank  Kasmo Cloud Solutions   Collabera  Virtusa Consulting  CenturyLink  HCL Technologies  Tata Consultancy (TCS)  Accenture  Polaris  Amdocs  Cognizant (CTS)  IBM  nagarvision   Synechron  Global Logic      basic        frequent


 Q9. Which interface does java.util.Hashtable implement ?

a. List
b. Set
c. Collection
d. Map
Core Java
Anonymous
Ans. Map

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

   Like      Discuss      Correct / Improve     hashtable   java   collections



Do you think these are the Best Java Frameworks ?

OpenXavaSPRING MVCApache StripesCheck everything
that is Best in Java

Click Here



 Q10. Which of the following is false ?

a. HashMap came before HashTable.
b. HashMap allows null values whereas Hashtable doesn’t allow null values.
c. HashTable and HashMap allow Key-Value pairs.
d. Hashtable is synchronized whereas HashMap is not.
Anonymous
Ans. HashMap came before HashTable.

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

   Like      Discuss      Correct / Improve     map   hashmap   hashtable   collection   java

Try 2 Question(s) Test


 Q11. Which of the collections allows null as the key ?

a. HashTable
b. HashMap
c. TreeMap
d. LinkedHashMap
Core Java
Anonymous
Ans. HashTable

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

   Like      Discuss      Correct / Improve     java   collections   map  hashtable     Accenture      basic        frequent


 Q12. Difference between concurrentHashMap and HashTable ?Core Java2017-01-29 18:37:04

Ans. HashTable locks the complete collection to provide synchronization whereas ConcurrentHashMap only locks segments to achieve synchronization and hence better efficient and faster.

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

   Like      Discuss      Correct / Improve     concurrentHashMap  HashTable  Map  Collections     Talentica  BlackRock


 Q13. isnt the use of HashTable and ConcurrentHashMap the same, i.e providing synchronized map collection ?Core Java2017-01-29 18:38:52

Ans. Yes, they both aim at providing synchronized access to the Map collection. The only difference is in their implementation. ConcurrentHashMap came after HashTable and hence technically more efficient as it doesn't lock the complete map while accessing it.

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

   Like      Discuss      Correct / Improve     HashTable  ConcurrentHashMap  map  Collections


 Q14. How to implement a hashtable ?Data Structure2017-04-20 09:38:10

 This question was recently asked at 'MarkMonitor'.This question is still unanswered. Can you please provide an answer.


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

   Like      Discuss      Correct / Improve     hashtable     MarkMonitor


 Q15. How ConcurrentHashMap provides better performance compared to HashTable ?Core Java2017-09-03 11:44:29

Ans. ConcurrentHashMap uses multiple buckets to store Data and hence avoid read locks which facilitates better performance.

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

   Like      Discuss      Correct / Improve     ashTabl      expert        rare


 Q16. Isnt the use of HashTable and ConcurrentHashMap the same, i.e providing synchronized map collection ?Core Java2018-08-30 08:37:45

 This question was recently asked at 'Tata Consultancy'.This question is still unanswered. Can you please provide an answer.


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

   Like      Discuss      Correct / Improve     synchronized collections  hashtable  ConcurrentHashMap     Tata Consultancy




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: