Q1: What is the difference between ArrayList and Vector ?
Ans:
Vector is synchronized while ArrayList is not . Vector is slow while ArrayList is fast. Every time when needed, Vector increases the capacity twice of its initial size while ArrayList increases its ArraySize by 50%.
Q2 What is the difference between HashMap and Hashtable ?
Ans:
a. HashMap allows one null key and any number of null values while Hashtable does not allow null keys and null values.
b. HashMap is not synchronized or thread-safe while Hashtable is synchronized or thread-safe.
Q3 What is the difference between Iterator and ListIterator.
Ans:
Using Iterator we can traverse the list of objects in forward direction . But ListIterator can traverse the collection in both directions that is forward as well as backward.
Q4 What is the difference between HashSet and TreeSet ?
Ans:
a. HashSet maintains the inserted elements in random order while TreeSet maintains elements in the sorted order
b. HashSet can store null object while TreeSet can not store null object.
Q5 What is the difference between HashMap and ConcurrentHashMap ?Ans:
a. HashMap is not synchronized while ConcurrentHashMap is synchronized.
b. HashMap can have one null key and any number of null values while ConcurrentHashMap does not allow null keys and null values .
Ans:
Vector is synchronized while ArrayList is not . Vector is slow while ArrayList is fast. Every time when needed, Vector increases the capacity twice of its initial size while ArrayList increases its ArraySize by 50%.
Q2 What is the difference between HashMap and Hashtable ?
Ans:
a. HashMap allows one null key and any number of null values while Hashtable does not allow null keys and null values.
b. HashMap is not synchronized or thread-safe while Hashtable is synchronized or thread-safe.
Q3 What is the difference between Iterator and ListIterator.
Ans:
Using Iterator we can traverse the list of objects in forward direction . But ListIterator can traverse the collection in both directions that is forward as well as backward.
Q4 What is the difference between HashSet and TreeSet ?
Ans:
a. HashSet maintains the inserted elements in random order while TreeSet maintains elements in the sorted order
b. HashSet can store null object while TreeSet can not store null object.
Q5 What is the difference between HashMap and ConcurrentHashMap ?Ans:
a. HashMap is not synchronized while ConcurrentHashMap is synchronized.
b. HashMap can have one null key and any number of null values while ConcurrentHashMap does not allow null keys and null values .
No comments:
Post a Comment