Tuesday, April 30, 2019

Collections In Java Interview Questions

Q:-  What is the Collection framework in Java?
Collection framework that provides an architecture to store and manipulate the data in form of group of objects it is a combination of classes and interface. It provides various interfaces like List, Set,Queue, Deque, SortedSet, NavigableSet, BlockingQueue, TransferQueue, BlockingDeque and  classes such as ArrayList, Vector, Stack, and HashSet.

Q:- Difference between Collection and Collections in Java?
Collection: Collection is a interface present in java.util.package. It is used to represent a group of individual objects as a single unit.The List, Set, and Queue are the main sub-interfaces of the collection interface.
Collections: Collections is a utility class present in java.util.package. that has some set of operations like sorting and searching which is used to operate on collections

Collection Implementations


Q:-  Explain the hierarchy of the Collection framework in Java.

Java Collections Framework Hiechrary

Q:- Explain the hierarchy of the Collection framework in Java.
Q:- What are the main differences between array and collection?
Q:- Explain various interfaces used in Collection framework?
Q:- What is the difference between ArrayList and Vector?
Q:- What is the difference between ArrayList and LinkedList?
Q:- What is the difference between Iterator and ListIterator?
Q:- What is the difference between Iterator and Enumeration?
Q:- What is the difference between List and Set?
Q:- What is the difference between HashSet and TreeSet?
Q:- Differentiate between HashSet and TreeSet. When would you prefer TreeSet to HashSet?
Q:- Can you add a null element into a TreeSet or HashSet?
Q:- What is the difference between Set and Map?
Q:- What is the difference between HashSet and HashMap?
Q:- What is the difference between HashMap and TreeMap?
Q:- What is the difference between HashMap and Hashtable?
Q:- What is the difference between Comparable and Comparator?
Q:- What do you understand by BlockingQueue?
Q:- What is a priority queue in Java?
Q:- What is the advantage of Properties file?
Q:- What does the hashCode() method?
Q:- Why we override equals() method?
Q:- How to synchronize List, Set and Map elements?
Q:- What is the advantage of the generic collection?
Q:- What is hash-collision in Hashtable and how it is handled in Java?
Q:- What is the Dictionary class?
Q:- What is the default size of load factor in hashing based collection?
Q:- What do you understand by fail-fast?
Q:- Explain fail-fast and fail-safe iterators. Differentiate between them.
Q:- What is the purpose of RandomAccess Interface? Name a collection type which implements this interface.
Q:- What is the difference between Array and ArrayList?
Q:- What is the difference between the length of an Array and size of ArrayList?
Q:- How to convert ArrayList to Array and Array to ArrayList?
Q:- How to make Java ArrayList Read-Only?
Q:- How to remove duplicates from ArrayList?
Q:- How to reverse ArrayList?
Q:- How to sort ArrayList in descending order?
Q:- How to synchronize ArrayList?
Q:- When to use ArrayList and LinkedList?
Q:- Write a program to shuffle all the elements of a collection in Java.
Q:- What is the difference between Collection Vs Stream in java 8?
Answer:- Collection Vs Stream API In Java 8
Collections Tutorials
  • List Collection
  • Set Collection
  • Map Collection
  • Queue Collection
  • SortedMap and TreeMap
  • SortedSet and TreeSet
  • NavigableMap and TreeMap
  • NavigableSet and TreeSet
  • equals() and hashCode()
  • Object Ordering
  • Generic Methods & Classes
  • Generic Wildcards
  • Collections & Thread Safety
  • Java 8 Stream API
  • Stream Intermediate Operations
  • Stream Terminal Operations


Related Tutorials

No comments:

Post a Comment