Top 100 Java Collections Interview Questions


This book contains Java Collection interview questions that an interviewer asks. It is a compilation of advanced Java Collection interview questions after attending dozens of technical interviews in top-notch companies like- Facebook, Google, Ebay, Amazon etc.

Each question is accompanied with an answer because you want to save your time while preparing for an interview.

The difficulty rating on these Questions varies from a Junior level programmer to Architect level.

Once you go through them in the first pass, mark the questions that you could not answer by yourself. Then, in second pass go through only the difficult questions.

After going through this book 2-3 times, you will be very well prepared to face a technical interview on Java Collection for an experienced programmer.

Read Top 100 Java Collections Interview Questions & Answers book on Amazon.com

Sample questions are:

  • What is the difference between Collection and Collections Framework in Java?
  • What are the main benefits of Collections Framework in Java?
  • What is the root interface of Collection hierarchy in Java?
  • What are the main differences between Collection and Collections?
  • What are the Thread-safe classes in Java Collections framework?
  • How will you efficiently remove elements while iterating a Collection?
  • How will you convert a List into an array of integers like- int[]?
  • How will you convert an array of primitive integers int[] to a List collection?
  • How will you run a filter on a Collection?
  • How will you convert a List to a Set?
  • How will you remove duplicate elements from an ArrayList?
  • How can you maintain a Collection with elements in Sorted order?
  • What is the difference between Collections.emptyList() and creating new instance of Collection?
  • How will you copy elements from a Source List to another list?
  • What are the Java Collection classes that implement List interface?
  • What are the Java Collection classes that implement Set interface?
  • What is the difference between an Iterator and ListIterator in Java?
  • What is the difference between Iterator and Enumeration?
  • What are the differences between the two data structures: a Vector and an ArrayList?
  • What are the differences between Collection and Collections in Java?
  • What is the difference between an ArrayList and a LinkedList data structure?
  • In which scenario, LinkedList is better than ArrayList in Java?
  • What are the differences between a List and Set collection in Java?
  • What is the difference between a Set and a Map in Java?
  • What are the differences between a HashSet and TreeSet collection in Java?
  • In Java, how will you decide when to use a List, Set or a Map collection?
  • What is the use of a Dictionary class?
  • What is the default size of load factor in a HashMap collection in Java?
  • What is the significance of load factor in a HashMap in Java?
  • What are the major differences between a HashSet and a HashMap?
  • What are the differences between a HashMap and a Hashtable in Java?
  • What are the similarities between a HashSet and a HashMap in Java?
  • What are the differences between a HashMap and a TreeMap?
  • What are the differences between Comparable and Comparator?
  • In Java, what is the purpose of Properties file?
  • What is the reason for overriding equals() method?
  • How does hashCode() method work in Java?
  • How can we synchronize the elements of a List, a Set or a Map?
  • Is it a good idea to use Generics in collections?
  • What is Hash Collision? How Java handles hash-collision in HashMap?
  • What are the Hash Collision resolution techniques?
  • What is the difference between Queue and Stack data structures?
  • What is an Iterator in Java?
  • What is the difference between Iterator and Enumeration in Java?
  • What is the design pattern used in the implementation of Enumeration in Java?
  • Which methods do we need to override to use an object as key in a HashMap?
  • How will you reverse a List in Java?
  • How will you convert an array of String objects into a List?
  • What is the difference between peek(), poll() and remove() methods of Queue interface in java?
  • What is the difference between Array and ArrayList in Java?
  • How will you insert, delete and retrieve elements from a HashMap collection in Java?
  • What are the main differences between HashMap and ConcurrentHashMap in Java?
  • What is the increasing order of performance for following collection classes in Java?
  • Why does Map interface not extend Collection interface in Java?
  • What are the different ways to iterate elements of a list in Java?
  • What is CopyOnWriteArrayList? How it is different from ArrayList in Java?
  • How remove() method is implemented in a HashMap?
  • What is BlockingQueue in Java Collections?
  • How is TreeMap class implemented in Java?
  • How does ConcurrentHashMap work in Java?
  • What is the importance of hashCode() and equals() methods?
  • What is the contract of hashCode() and equals() methods in Java?
  • What is an EnumSet in Java?
  • What are the main Concurrent Collection classes in Java?
  • How will you convert a Collection to SynchronizedCollection in Java?
  • How IdentityHashMap is different from a regular Map in Java?
  • What is the main use of IdentityHashMap?
  • How can we improve the performance of IdentityHashMap?
  • Is IdentityHashMap thread-safe?
  • What is a WeakHashMap in Java?
  • How can you make a Collection class read Only in Java?
  • When is UnsupportedOperationException thrown in Java?
  • Let say there is a Customer class. We add objects of Customer class to an ArrayList. How can we sort the Customer objects in ArrayList by using customer firstName attribute of Customer class?
  • What is the difference between Synchronized Collection and Concurrent Collection?
  • What is the scenario to use ConcurrentHashMap in Java?
  • How will you create an empty Map in Java?
  • What is the difference between remove() method of Collection and remove() method of Iterator?
  • Between an Array and ArrayList, which one is the preferred collection for storing objects?
  • Is it possible to replace Hashtable with ConcurrentHashMap in Java?
  • How CopyOnWriteArrayList class is different from ArrayList and Vector classes?
  • Why ListIterator has add() method but Iterator does not have?
  • Why do we sometime get ConcurrentModificationException during iteration?
  • How will you convert a Map to a List in Java?
  • How can we create a Map with reverse view and lookup in Java?
  • How will you create a shallow copy of a Map?
  • Why we cannot create a generic array in Java?
  • What is a PriorityQueue in Java?
  • What are the important points to remember while using Java Collections Framework?
  • How can we pass a Collection as an argument to a method and ensure that method will not be able to modify it?
  • Can you explain how HashMap works in Java?
  • Can you explain how HashSet is implemented in Java?
  • What is a NavigableMap in Java?
  • What is the difference between descendingKeySet() and descendingMap() methods of NavigableMap?
  • What is the advantage of NavigableMap over Map?
  • What is the difference between headMap(), tailMap() and subMap() methods of NavigableMap?
  • How will you sort objects by Natural order in a Java List?
  • How can we get a Stream from a List in Java?
  • Can we get a Map from a Stream in Java?
  • What are the popular implementations of Deque in Java?

Read Top 100 Java Collections Interview Questions & Answers book on Amazon.com

Read the full book at www.amazon.com
Posted in Collections

Leave a Reply

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

*