Java MCQ: What is a Hashtable in Java?
a) A synchronized map that does not allow null keys or values
b) A map that maintains insertion order
c) A map that allows null values
d) A map that stores keys in a sorted order
Answer:
a) A synchronized map that does not allow null keys or values
Explanation:
A Hashtable
in Java is a synchronized map that does not allow null keys or values. It is similar to HashMap
but is thread-safe, making it suitable for use in multithreaded environments.
Understanding Hashtable
is important for managing key-value pairs in environments where synchronization is required.
Reference links:
https://www.rameshfadatare.com/learn-java-programming/
https://www.javaguides.net/p/java-tutorial-learn-java-programming.html