Java collections interview questions

Java collections interview questions

Java collections interview questions included set of questions related to all java collections topic separately

Topic 1: Java collections interview questions miscellaneous

1. What is UnsupportedOperationException ?
2. What are wrapper classes ?
3. What is native method ?
4. What is purpose of System class ?
5. What is Java Collections Framework ? List out some benefits of Collections framework ?
6. Which collection classes are thread-safe ?
7. What are concurrent Collection Classes ?
8. Why Collection does not extend Cloneable and Serializable interfaces ?
9. What is Dictionary class ?
10. What is benefit of Generics in Collections Framework ?
11. What are basic interfaces of Java Collections Framework ?
12. What is BlockingQueue ?
13. What is difference between Queue and Stack ?
14. What is Collections Class?
15. How you create read only collection ?
16. How to create synchronized collection from collection ?
17. Common algorithms list implemented Collections Framework ?
18. Describe Big-O notation ?
19. Define Priority Queue java ?

 

Topic 2: Java collections interview questions on Iterator Interface

1. What is an Iterator ?
2. What is difference between Iterator and ListIterator ?
3. How do you traverse through collection using its Iterator ?
4. What is difference between Enumeration and Iterator interface ?
5. Why there is not method like Iterator.add() to add elements to collection ?
6. Tell me reason Iterator don’t have method to get next element directly without moving the cursor ?
7. What do you understand by iterator fail-fast property ?
8. Why there are no concrete implementations of Iterator interface ?
9. How do you remove elements during Iteration ?
10. What are different ways to iterate over a list ?
11. How to avoid ConcurrentModificationException while iterating a collection ?
12. What is ListIterator ?

 

Topic 3: Java collections interview questions on Comparable and Comparator Interface

1. What is Comparable interface ?
2. What is difference between Comparable and Comparator interface ?
3. How do you compare object using Comparable interface ?
4. How do you compare object using Comparator interface ?
5. Sample code which compare two object using Comparator ?
6. Sample code which compare two object using Comparable ?

 

Topic 4: Java collections interview questions on Java Set Interface

1. What is Set interface ?
2. What are main Implementations of Set interface ?
3. What is HashSet ?
4. What is TreeSet ?
5. What is EnumSet ?
6. Difference between HashSet and TreeSet ?
7. What is difference between List and Set ?
8. What is KeySet View ?
9. What is EntrySet View ?

 

Topic 5: Java collections interview questions on Map HashMap HashSet and HashTable

1. What is weak hashing?
2. What is difference between hash code and equals?
3. What is difference between Hash table and Hash map?
4. How will you decide when to use HashMap or TreeMap ?
5. What is Map ?
6. What are the main Implementations of the Map interface ?
7. Can you make List Set and Map elements synchronized ?
8. Why Map interface not extend Collection interface ?
9. Can we use any class as Map key ?
10. What are different Collection views provided by Map interface ?
11. What is the use of a Hash Map? What happens to the value when a similar object is used for a key ?
12. What is difference between Collection and Set Interface ?
13. What is TreeMap ?
14. What is difference between HashMap and TreeMap ?
15. What is difference between HashSet and HashMap ?
16. How Hashtable internally maintain key value pairs ?
17. What is hash-collision in Hashtable and how it is handled in Java ?
18. How HashMap works in Java?
19. What is importance of hashCode() and equals() methods ?

 

Topic 6: Java collections interview questions on ArrayList LinkedList Array and Vector

1. What is difference between ArrayList and map?
2. Difference between ArrayList and Vector ?
3. How to convert ArrayList to Arrays ?
4. Why insertion and deletion in ArrayList slow compared to LinkedList ?
5. Why are Iterators returned by ArrayList called Fail Fast ?
6. How do you decide when to use ArrayList and LinkedList?
7. What are advantages of ArrayList over arrays ?
8. What is List interface ?
9. What are main implementations of List interface ?
10. What is set and list in Java ?
11. What is difference between fail-fast and fail-safe ?
12. How will you sort array of object ?
13. What is difference between ArrayList and LinkedList ?
14. How do you sort an ArrayList of user defined objects ?
15. How will you sort array list ?
16. How can we sort list of Objects ?

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *