What is Collection API?
It defines set of classes and interfaces which can be
used for representing a group of objects as single entity
What is Collection framework?
It defines set of classes and inter faces which can be
used for representing a group of objects as single entity
What is difference between Collections and Collection?
Collection is an interface which can be used for representing
a group of individual objects as single entity and it acts as root
interface of collection frame work. Collections is an utility class
to define several utility methods for Collection implemented class objects.
Explain about Collection interface?
-
This interface can be used to represent a group of objects
as a single entity.
-
It acts as root interface for entire collection framework.
-
It defines the most commonly used methods which can be applicable
for any collection implemented class object.
Explain about List interface?
List interface is a child interface of Collection interface.
This can be used to represent group of individual objects in as a single
entity where
-
Duplicates are allowed
-
Insertion order is preserved
Explain about Set interface?
Set is a child interface of Collection interface. it can
be used to represent a group of individual objects as a single entity where
-
Duplicate objects are not allowed.
-
Insertion order is not preserved
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
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.
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.
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.
|