Java Collections Interview Questions and Answers




1.       What are Collection related features in Java 8?
2.       What is Java Collections Framework? List out some benefits of Collections framework?
3.       What is the benefit of Generics in Collections Framework?
4.       What are the basic interfaces of Java Collections Framework?
5.       Why Collection doesn’t extend Cloneable and Serializable interfaces?
6.       Why Map interface doesn’t extend Collection interface?
7.       What is an Iterator?
8.       What is difference between Enumeration and Iterator interface?
9.       Why there is not method like Iterator.add() to add elements to the collection?
10.   Why Iterator don’t have a method to get next element directly without moving the cursor?
11.   What is different between Iterator and ListIterator?
12.   What are different ways to iterate over a list?
13.   What do you understand by iterator fail-fast property?
14.   What is difference between fail-fast and fail-safe?
15.   How to avoid ConcurrentModificationException while iterating a collection?
16.   Why there are no concrete implementations of Iterator interface?
17.   What is UnsupportedOperationException?
18.   How HashMap works in Java?
19.   What is the importance of hashCode() and equals() methods?
20.   Can we use any class as Map key?
21.   What are different Collection views provided by Map interface?
22.   What is difference between HashMap and Hashtable?
23.   How to decide between HashMap and TreeMap?
24.   What are similarities and difference between ArrayList and Vector?
25.   What is difference between Array and ArrayList? When will you use Array over ArrayList?
26.   What is difference between ArrayList and LinkedList?
27.   Which collection classes provide random access of it’s elements?
28.   What is EnumSet?
29.   Which collection classes are thread-safe?
30.   What are concurrent Collection Classes?
31.   What is BlockingQueue?
32.   What is Queue and Stack, list their differences?
33.   What is Collections Class?
34.   What is Comparable and Comparator interface?
35.   What is difference between Comparable and Comparator interface?
36.   How can we sort a list of Objects?
37.   While passing a Collection as argument to a function, how can we make sure the function will not be able to modify it?
38.   How can we create a synchronized collection from given collection?
39.   What are common algorithms implemented in Collections Framework?
40.   What is Big-O notation? Give some examples?
41.   What are best practices related to Java Collections Framework?
42.   What is Java Priority Queue?
43.   Why can’t we write code as List numbers = new ArrayList();?
44.   Why can’t we create generic array? or write code as List[] array = new ArrayList[10];

No comments:

Post a Comment