Map vs Set vs List
ArrayList vs Vector
HashMap vs HashTable
HashMap vs HashSet
Iterator vs Enumeration
Fail-fast and Fail-safe Iterators
Iterator vs ListIterator
Why ListIterator has added() method but Iterator does not have it?
Comparable and Comparator Interface
Working example of compareTo(), comparable, equals(), hashCode().
Synchronized Collection vs Concurrent collection
ArrayList vs Vector vs CopyOnWriteArrayList
HashMap vs HashTable vs ConcurrentHashMap
Can we replace Hashtable with ConcurrentHashMap?
Queue - BlockingQueue
HashTable vs ConcurrentHashMap (putIfAbsent)
What is lock striping in java?
poll() vs remove()
Singleton Design Pattern
Iterator Design Pattern.
2.) How Hasmap get() and remove() works in java?
3.) How Hashset works in java?
4.) How does Linkedlist implemented in java? Is it singly linkedlist or doubly linked list?
5.) What is Marker interface or Tag interface? Examples of it(Serializable, Clonnable, RMI and Remote interfaces, RandomAccess...)
6.) Which is better to use? Annotations or Marker interface?
7.) What is Clonnable interface? Why it is use? When it is used? How it is used?
8.) What is Serializable interface? Why it is use? When it is used? How it is used?
9.) What is TreeMap, Naviagable Map and WeakHashMap, IdentityHashMap?
10.) WeakReference vs SoftReference vs PhantomReference vs Strong reference
11.) How can an Arraylist be synchronized without using Vector?
Ans) Arraylist can be synchronized using:
Collections.synchronizedList(List list)
Collections.synchronizedMap(Map map)
Collections.synchronizedCollection(Collection c)
12.) How do you remove an entry from a Collection? OR
What is difference between remove() method of Collection and remove() method of Iterator?
Which one you will use, while removing elements during iteration.
Thread:
What is the difference between start and run method in Java Thread?
( thread.start() vs thread.run() )
How to avoid deadlock?
Write producer-consumer problem?
Solve it by using wait() and notify(). Solve it by using BlockinQueue. Which is better?
What are the other thread scheduler? like quartz, threadpool Executors?
ArrayList vs Vector
HashMap vs HashTable
HashMap vs HashSet
Iterator vs Enumeration
Fail-fast and Fail-safe Iterators
Iterator vs ListIterator
Why ListIterator has added() method but Iterator does not have it?
Comparable and Comparator Interface
Working example of compareTo(), comparable, equals(), hashCode().
Synchronized Collection vs Concurrent collection
ArrayList vs Vector vs CopyOnWriteArrayList
HashMap vs HashTable vs ConcurrentHashMap
Can we replace Hashtable with ConcurrentHashMap?
Queue - BlockingQueue
HashTable vs ConcurrentHashMap (putIfAbsent)
What is lock striping in java?
poll() vs remove()
Singleton Design Pattern
Iterator Design Pattern.
Commonly asked interview questions:
1.) How Hashmap works in java? 2.) How Hasmap get() and remove() works in java?
3.) How Hashset works in java?
4.) How does Linkedlist implemented in java? Is it singly linkedlist or doubly linked list?
5.) What is Marker interface or Tag interface? Examples of it(Serializable, Clonnable, RMI and Remote interfaces, RandomAccess...)
6.) Which is better to use? Annotations or Marker interface?
7.) What is Clonnable interface? Why it is use? When it is used? How it is used?
8.) What is Serializable interface? Why it is use? When it is used? How it is used?
9.) What is TreeMap, Naviagable Map and WeakHashMap, IdentityHashMap?
10.) WeakReference vs SoftReference vs PhantomReference vs Strong reference
11.) How can an Arraylist be synchronized without using Vector?
Ans) Arraylist can be synchronized using:
Collections.synchronizedList(List list)
Collections.synchronizedMap(Map map)
Collections.synchronizedCollection(Collection c)
12.) How do you remove an entry from a Collection? OR
What is difference between remove() method of Collection and remove() method of Iterator?
Which one you will use, while removing elements during iteration.
Thread:
What is the difference between start and run method in Java Thread?
( thread.start() vs thread.run() )
How to avoid deadlock?
Write producer-consumer problem?
Solve it by using wait() and notify(). Solve it by using BlockinQueue. Which is better?
What are the other thread scheduler? like quartz, threadpool Executors?
List | Set | Map |
Ordered
collection (It preserves the order on which an element is inserted. ) (Also known as Dynamic Array.) |
Unordered
collection (It does not preserve the order.) (We can have SortedSet which offers to sort functionality e.g: TreeSet.) (Also we can change/override it by using Comparator and Comparable. ) |
Key-Value based collection |
List
allows duplicate values. It can store multiple times null as value. |
Set
does not allow duplicate values. So it can store only one time null as value. (Duplication of object is detected by using equals() ) (If two objects are equal using equals() then the later object will replace the former object.) (In case of SortedSet like TreeSet, compareTo() is used to compare object and decide whether an object is duplicate or not. ) |
Duplicate
keys are not allowed. It can contain only one null key but can contain duplicate values. |
e.g. ArrayList, LinkList, Vector | e.g HashSet | e.g HashMap, LinkedHashMap, TreeMap |