Question1:You need to insert huge amount of objects and randomly delete them one by one. Which Collection data structure is best pet?
Answer:
LinkedList.
Question2:What goes wrong if the HashMap key has same hashCode value?
Answer:
It leads to ‘Collision’ wherein all the values are stored in same bucket. Hence, the searching time increases quad radically.
Question:3 If hashCode() method is overridden but equals() is not, for the class ‘A’, then what may go wrong if you use this class as a key in HashMap?
Answer:
Question:4. How will you remove duplicate element from a List?
Answer:
Add the List elements to Set. Duplicates will be removed.
Question:5. How will you synchronize a Collection class dynamically?
Answer:
Use the utility method
java.util.Collections.synchronizedCollection(Collection c)
Courtsey:
http://excusemeworld.com
No comments:
Post a Comment