1.

How many overloaded add() and addAll() methods are available in the List interface? Describe the need and uses.

Answer»

There are a total of 4 overloaded methods for add() and addAll() methods available in List Interface. The below table states the DESCRIPTION of all.

Return TypeMethod Description
booleanadd(Element e): This method is used for adding the element at the end of the List. The Datatype of the element is of any type it has been INITIALLY assigned with. It returns the boolean indicating successfully inserted or not.
voidadd(int index, Element e): This method is the overloaded version of add() method. In this, along with the element, the index is ALSO passed to the method for the specific index the value needs to be inserted. 
booleanaddAll(Collection <extends ? Element > c): This method helps to add all elements at the end of collections from the list received in the parameter. It contains an iterator that helps to ITERATE the list and add the elements to the collection.
booleanaddAll(int index, Collection <extends ? Element > c): This is the overloaded method for addAll() method. In this along with the list, we can pass the specified index from which the list elements need to be added.


Discussion

No Comment Found