Search your topic in Java2share
Home > FAQs
eXTReMe Tracker


Collections FAQs


Q11.  Explain about SortedSet interface?

it is child interface of Set interface. it can be used to represent a group of individual objects in to a single entity where

  • All the objects are arranged in some sorting order (Can be natural sorting order or customizede).
  • Duplicates are not allowed.

Q12.  Explain about NavigableSet ?

It is child interface of SortedSet and provides several utility methods for navigation purposes

  • It doesn’t allows duplicates                                
  • Insertion order is preserved
  • It is introduced in 1.6 version

Q13. Explain about Queue interface?

If we want to represent a group of individual objects prior to processing, then we should go for Queue interface. It is child interface of Collection interface.

It has introduced in 1.5 version.

Q14. Explain about Map interface?

Remember it is not a child Interface of Collection Interface and hence Map and Collection Interfaces doesn’t have any relationship.

  • It can be used for representing a group of Objects as key, value pairs.
  • Both keys and values should be objects
  • Keys can t be duplicated but values can be duplicated.
  • it has  introduced in 1.2 version

Q15. Explain about SortedMap ?

  • If we want to represent a group of objects as key value pairs where all the entries are arranged according some sorting order of keys then we should go for SortedMap.
  • It is child interface of Map.
  • It has  introduced in 1.2 version

Q16. Explain about NavigableMap?

  • It is child interface of SortedMap and defines several method for navigation purpose
  • It is introduced in 1.6 version

Q17.  Explain about ArrayList class?

 ArrayList is a Collection which can be used to represent a group of objects as a single entity.

  • it is a implemented class for  List interface
  • Introduced in 1.2 version
  • The underlying data structure is resizable or growable array.
  • Insertion order is preserved
  • Duplicates are allowed
  • Heterogeneous objects are allowed
  • null insertion is possible
  • This  class implements RandomAccess , Serializable , Cloneable interfaces
  • Best choice  for retrieval purpose and worst if our frequent operation is insertion or deletion in the middle

Q18. What is RandomAccess Interface?

  • If a collection class implements RandomAccess interface then we can access any of its element with the same speed.
  • RandomAccess interface is marker interface and it dosent contains any methods.
  • ArrayList and vector classes implements this interface.

Q19. Explain about LinkedList class?

LinkedList is a Collection implemented class which can be used for representing a group of objects as a single entity.

  • LinkedList is the implemetation class for List interface
  • Introduced in 1.2 version
  • Underlying data Structure is   DoubleLinkedList
  • Allows duplicates
  • Insertion order is preserved
  • Allows heterogeneous objects
  • null insertion is possible
  • LinkedList class implements Seriallizable and Cloneable interface but not RandomAccess interface
  • Best choice  if frequent operation is insertion or deletion an objects in middle  but worst choice if frequent operation is retrieval.

Q20. Explain about Vector class?

     Vector is a legacy collection class which can be used to represent a group of objects.

  • Introduced in 1.0 version. it is legacy class
  • The underlying data structure is resizable or growable array.
  • Insertion order is preserved
  • Duplicates are allowed
  • Heterogeneous objects are allowed
  • It is a implemented class for  List interface
  • null insertion is possible
  •  Vector class implements RandomAccess ,Serializable,Cloneable interfaces
  • Best Choice if frequent operation is retrieval and worst choice if frequent operation is insertion or deletion in the middle.
  • All methods present in Vector class are synchronized hence Vector class object is thread safe.