Enter your E-mail Address below for Free E-mail Alerts right Into your Inbox: -

Thursday

Java Collection Interview Questions and Answers

  1. Difference between ArrayList and Vector?
  • ArrayList is not Synchronized
  • ArrayList Increases size only by half
  • Vector is Synchronized
  • Vector Increases size by double      
    2. Difference between ArrayList and LinkedList?
  • Both implement the list interface
  • Searching an element in ArrayList is easy but deletion is slow
  • viceversa in LinkedList 
  • Searching an element in LinkedList is slow but deletion is fast
  • Insertion is easy in LinkedList and slow in ArrayList
  • For Random access of data use ArrayList
  • For Fast Insertion and Deletion use LinkedList 
    3. Difference between Iterator and ListIterator?
  • Iterator Traverse only in forward direction
  • ListIterator Traverse  in both direction
  • Iterator is used with both List and Set
  • ListIterator is used only with List
  • Iterator not allows removal of an element while iterating it
  • ListIterator allows removal of an element while iterating it
    4. Difference between List and Set?
  • List allows duplicate values
  • Set allows only unique values
   5. Difference between List and Map?
  • List contains only values
  • Map contains both key and value pairs
  6. Difference between Set and Map?
  • Set contains only values
  • Map contains both key and value pairs
 7. Difference between HashMapand TreeMap?
  • HashMap doesn't maintain an order in which the elements are inside it
  • TreeMap maintains an order in which the values are inserted in it
 8. Difference between HashMap and TreeMap
  • HashMap is not synchronized.
  • Hashtable is synchronized.
  • HashMap can contain one null key and multiple null values.
  • Hashtable cannot contain any null key or null value.

No comments:

Post a Comment