Important Java Interview Questions - Part 3

I'm sharing my experience with you as these are the questions which have been asked to me while interviewing on java profile.

Why we need Linkedhashmap?

1.     LinkedHashMap will iterate in the order in which the entries were put into the map. LinkedHashMap maintain insertion order of keys, i.e the order in which keys are inserted into LinkedHashMap. On the other hand HashMap doesn't maintain any order or keys or values.
2.     Null Values are allowed in LinkedHashMap.
3.     In terms of Performance there is not much difference between HashMap and LinkedHashMap but yes LinkedHashMap has more memory foot print than HashMap to maintain doubly linked list which it uses to keep track of insertion order of keys.
4.     A HashMap has a better performance than a LinkedHashMap because a LinkedHashMap needs the expense of maintaining the linked list.
5.     The LinkedHashMap implements a normal hashtable, but with the added benefit of the keys of the hashtable being stored as a doubly-linked list. Both of their methods are not synchronized.


If you still have any question you can reach me any time through email (jigyasu2010@hotmail.com)

Comments

Popular posts from this blog

How Method Overloading Helping in Java - Part 9

Design Patterns -- part 1

Access Modifiers in java