Google Interview Question
1,072 Interview Reviews |
Back to all Google Interview Questions & Reviews
Interview questions and reviews posted anonymously by interview candidates
Interview Question for Software Engineer at Google:
Helpful Question?
Yes |
No
Inappropriate?
Answers & Comments (2)
There are 3 differences:
1. Hashtable is completely synchronized. There is no concurrent access allowed but it is thread-safe in the sense that only a single thread can access the table. HashMap is not thread-safe in any ways.
2. Hashtable does not allow null keys or null values(you will get a NPE). HashMap allows both null keys and values.
3. Hashtable's enumerator is not fail safe, meaning if the map is changed during iteration, there is no way of knowing so. HashMap's iterator is fail safe, if the map is modified during iteration, you will get a ConcurrentModificationException.
Helpful Answer?
Yes |
No
Inappropriate?
Members can
answer or comment on this question
–
Join Now (It's Free) or
Sign In
1 of 1 people found this helpful
by NotAJavaProgrammer: