# Collections Interview Questions

Reference :

Collections

Questions :

1. How to find the missing number in integer array of 1 to 100?
2. How to find duplicate number on Integer array in Java?
3. How to check if array contains a number in Java?
4. How to find largest and smallest number in unsorted array?
5. How to find all pairs on integer array whose sum is equal to given number?
6. How to find repeated numbers in an array if it contains multiple duplicates?
7. Write a program to remove duplicates from array in Java?
8. How to sort an array in place using QuickSort algorithm? (
9. Write a program to find intersection of two sorted arrays in Java?
10. There is an array with every element repeated twice except one. Find that element?
11. How to find kth smallest element in unsorted array?
12. How to find kth largest element in unsorted array?
13. How to find common elements in three sorted array?
14. How find the first repeating element in an array of integers?
15. How to find first non-repeating element in array of integers?
16. How to find top two numbers from an integer array?
17. How to find the smallest positive integer value that cannot be represented as sum of any subset of a given array?
18. How to rearrange array in alternating positive and negative number?
19. How to find if there is a sub array with sum equal to zero?
20. How to remove duplicates from array in place?
21. How to remove a given element from array in Java?
22. How to merge sorted array?
23. How to find sub array with maximum sum in an array of positive and negative number?
24. How to find sub array with largest product in array of both positive and negative number?
25. Write a program to find length of longest consecutive sequence in array of integers?
26. How to find minimum value in a rotated sorted array?
27. Given an array of of size n and a number k, find all elements that appear more than n/k times?
28. How to reverse array in place in Java?
29. Difference between array and linked list data structure?
30. How to check if array contains a duplicate number?
31. Reference1
32. Array Tools
1. What is the use of the List interface?
2. What is ArrayList in Java?
3. How would you convert an ArrayList to Array and an Array to ArrayList?
4. How will you reverse a List?
5. What do you understand by LinkedList in Java? How many types of LinkedList does Java support?
6. Explain the Difference Between Linkedlist and Arraylist.
7. What is a Vector in Java?
8. What is the Stack class in Java and what are the various methods provided by it?
9. Differentiate between an Array and an ArrayList.
10. Differentiate between the Singly Linked List and Doubly Linked List.
11. Differentiate between ArrayList and Vector.
12. How to make Java ArrayList Read-Only?
13.  How to remove duplicates from ArrayList?
14. How to sort ArrayList in descending order?
15. How to synchronize ArrayList?
16. When to use ArrayList and LinkedList?
17. What are the important methods used in a linked list?
18. Name the collection classes that implement random access interface
19. How to join multiple ArrayLists?
20. How to measure the performance of an ArrayList?

1. What is Map interface in Java?
2. Why Map doesn’t extend the Collection Interface?
3. List down the different Collection views provided by the Map interface in the Java Collection framework?
4. Describe Various Implementations of the Map Interface and Their Use Case Differences.
5. Hashmap Implemented in Java
1. How Does Its Implementation Use Hashcode and Equals Methods of Objects
2. What Is the Time Complexity of Putting and Getting an Element from Such Structure
3. What Is the Purpose of the Initial Capacity and Load Factor Parameters of a Hashmap?What Are Their Default Values?
6. What is the main benefit of using the Properties file?
7. What is the ConcurrentHashMap in Java and do you implement it?
8. Differentiate between HashMap and HashTable.
9. Differentiate between HashMap and TreeMap.
10. What is hash-collision in Hashtable and how it is handled in Java?
11. What is the Dictionary class?
12. What is IdentityHashMap?
13. What is WeakHashMap?
14. Explain map. entry In Map
15. How to iterate map?
1. What is Set in Java Collections framework and list down its various implementations?
2. What is the HashSet class in Java and how does it store elements?
3. Can you add a null element into a TreeSet or HashSet?
4. What Is the Difference Between Hashset and Treeset?
5. Explain the emptySet() method in the Collections framework?
6. What is LinkedHashSet in Java Collections Framework?
7. Differentiate between HashSet and TreeSet.
8. What are the methods of Java TreeSet class?
9. Explain Linked HashSet
1. What are the various methods provided by the Queue interface?
2. What do you understand by BlockingQueue? (2)
3. What is a priority queue in Java
4. Differentiate between Queue and Deque.
1. What Are the Benefits of Their Implementation Compared to Regular Collections?
1. What Is the Difference Between Fail-Fast and Fail-Safe Iterators
2. What do you understand by Iterator in the Java Collection Framework?
3. Differentiate between Iterable and Iterator.
4. Differentiate between Iterator and Enumeration.
5. Differentiate between Iterator and ListIterator.
1. Describe the Collections Type Hierarchy, with a diagram
2. What Are the Main Interfaces, and What Are the Differences Between Them?
3. How Can You Use Comparable and Comparator Interfaces to Sort Collections?
4. What are the advantages of the Collection Framework in Java?
5. Why Collection doesn’t extend the Cloneable and Serializable interfaces?
6. List down the major advantages of the Generic Collection.
7. What is the need for overriding equals() method in Java?
8. How the Collection objects are sorted in Java?
9. Differentiate between Collection and Collections.
10. Differentiate between Comparable and Comparator
11. Differentiate between List and Set.
12. Differentiate between Set and Map.
13. Differentiate between List and Map.
14. Differentiate between Queue and Stack.
15. Differentiate between PriorityQueue and TreeSet.
16. Differentiate between HashSet and HashMap.
17. Differentiate between Iterable and Iterator.
18. Differentiate between failfast and failsafe.
19. How to synchronize List, Set and Map elements?
20. Explain Big-O notation with an example
21. Explain the best practices in Java Collection Framework
22. What is the difference between stack and Queue?
23. What is the difference between array and stack?
1. List down the major advantages of the Generic Collection.

Reference – For collections