Tutorials

Java Collections Interview Questions


Java Collection Interview Question 2


What are the classes implementing Set interface?

The classes implementing Set interface are:

  1. HashSet,
  2. LinkedHashSet,
  3. TreeSet

What are the classes implementing Map interface?

The classes implementing Map interface are:

  1. HashMap,
  2. LinkedHashMap,
  3. TreeMap

What is difference between ArrayList vs Vector?

Difference between Arraylist and vector in java is given below:

ArrayList vs Vector

Arraylist

Vector

Arraylist is non-synchronized in nature

Vector is synchronized in nature

Arraylist is better performance-wise in comparison to vector. As the Arraylist is non-synchronized so multiple threads can work on it simultaneously.

 

Vector lags performance wise when compared to ArrayList. Vector is thread-safe so when a thread is performing any operation on Vector then it gets a lock. If other thread wants to perform operation on same Vector then it needs to wait until the Vector is unlocked (released) by thread in action.

Arraylist increases by half of its size

Vector grows by double of its size.

 


 

What is the difference between ArrayList vs LinkedList?

To be updated soon...

 


What is the difference between ArrayList vs Array?

Difference between ArrayList and Array in java is given below:

Arraylist vs Array

ArrayList

Array

Arraylist is dynamic in nature.

Array is static in nature

Length of Arraylist is not pre-defined so the array can expand or shrink, if the requirement arises.

Length of array is pre-defined so the array cannot expand or shrink, if the requirement arises.

If the element is removed from arraylist then it shrinks thus saving memory from being wasted.

If the element is removed from the array then it doesn’t shrinks thus wasting memory.

ArrayList provides lots of pre-defined methods to work with.

Array provides just few pre-defined methods

 



Please Share this page
Views : 37
Like every other website we use cookies. By using our site you acknowledge that you have read and understand our Cookie Policy, Privacy Policy, and our Terms of Service. Learn more Got it!