What is the purpose of having the concept of overloading?

Answer Posted / anjani kumar jha

Suppose u write a method having two parameter and name of
that method is sum..................that is

public void sum(int a, int b)
{

}
Now suppose later the requirement is modified and u have to
told now sum method should pass three parameter in subclass,
and both the parameter which is called in superclass should
be same............what u gonna do .........

So u have to write to method in subclass one with two
parameter and another with three parameter and suppose again
the parameter increased and due to which u have to write 100
method like that...........that is sucide attempt for a
developer.

So sun told dont worry use the concept of overloading....
same class name with different parameter.......no need to
write the different method........for the same task....

use same method with different parameter is called overloading.

Is This Answer Correct ?    7 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is ternary operator in java?

611


Will the compiler creates a default constructor if I have a parameterized constructor in the class?

589


Why doesn't the java library use a randomized version of quicksort?

554


What are peerless components?

634


Why string is not thread safe?

553






When do we use hashset over treeset?

542


Can we override protected method in java?

595


What is the difference between array list and vector in java?

518


5 Coding best practices you learned in java?

648


Why can't we override private static methods?

530


How you can force the garbage collection?

548


Difference between static binding and dynamic binding?

578


What is thread life cycle in java?

588


When should I use stringbuffer?

584


What is the size of int?

611