DEV Community

Pramod Bablad
Pramod Bablad

Posted on

Top 70 Java Collections Interview Questions With Answers

1) What is the Java Collection Framework? Why it is introduced?
2) What is the root level interface of the Java collection framework?
3) What are the four main core interfaces of the Java collection framework?
4) Explain the class hierarchy of Java collection framework?
5) Why Map is not inherited from Collection interface although it is a part of Java collection framework?
6) What is Iterable interface?
7) What are the characteristics of List?
8) What are the major implementations of List interface?
9) What are the characteristics of ArrayList?
10) What are the three marker interfaces implemented by ArrayList?
11) What is the default initial capacity of ArrayList?
12) What is the main drawback of ArrayList?
13) What are the differences between array and ArrayList?
14) How Vector is different from ArrayList?
15) Why it is recommended not to use Vector class in your code?
16) What are the differences between ArrayList and Vector?
17) What are the characteristics of Queue?
18) Mention the important methods of Queue?
19) How Queue differs from List?
20) Which popular collection type implements both List and Queue?
21) What are the Characteristics of LinkedList?
22) What are the differences between ArrayList and LinkedList?
23) What is the PriorityQueue?
24) What are Deque and ArrayDeque? When they are introduced in Java?
25) What are the characteristics of sets?
26) What are the major implementations of Set interface?
27) What are the differences between List and Set?
28) What are the characteristics of HashSet?
29) How HashSet works internally in Java?
30) What are the characteristics of LinkedHashSet?
31) When you prefer LinkedHashSet over HashSet?
32) How LinkedHashSet works internally in Java?
33) What is SortedSet? Give one Example?
34) What is NavigableSet? Give one example?
35) What are the characteristics of TreeSet?
36) How HashSet, LinkedHashSet and TreeSet differ from each other?
37) What are the differences between Iterator and ListIterator?
38) How Map interface is different from other three primary interfaces of Java collection framework — List, Set and Queue?
39) What are the popular implementations of Map interface?
40) What are the characteristics of HashMap?
41) How HashMap works internally in Java?
42) What is hashing?
43) What is the initial capacity of HashMap?
44) What is the load factor of HashMap?
45) What is the threshold of an HashMap? How it is calculated?
46) What is rehashing?
47) How initial capacity and load factor affect the performance of an HashMap?
48) What are the differences between HashSet and HashMap?
49) What are the differences between HashMap and HashTable?
50) How do you remove duplicate elements from an ArrayList in Java?
51) Which Collection type do you suggest me If I want a sorted collection of objects with no duplicates?
52) What are the differences between Fail-Fast Iterators and Fail-Safe Iterators?
53) How do you convert an Array to ArrayList and an ArrayList to Array?
54) What is the difference between Collection and Collections?
55) How collections are different from Java 8 streams?
56) How do you convert HashMap to ArrayList in Java?
57) What keySet(), values() and entrySet() methods do?
58) What is the difference between Iterator and Java 8 Spliterator?
59) How do you sort an ArrayList?
60) What are the differences between HashMap and ConcurrentHashMap?
61) How do you make collections read-only or unmodifiable?
62) How do you reverse an ArrayList in Java?
63) What are the differences between synchronized HashMap, HashTable and ConcurrentHashMap?
64) How do you sort HashMap by keys?
65) How do you sort HashMap by values?
66) How do you merge two maps with same keys?
67) What do you know about Java 9 immutable collections? How they are different from unmodifiable collections returned by the Collections wrapper methods?
68) What do you know about Java 10 List.copyOf(), Set.copyOf() and Map.copyOf() methods? Why they are introduced?
69) What are the differences between Enumeration And Iterator?
70) Which is of type RandomAccess — ArrayList, LinkedList, HashSet and HashMap?

See the detailed answers at https://javaconceptoftheday.com/java-collections-interview-questions-with-answers/

Top comments (0)