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
How do you remove spaces in java?
How does compareto method work?
What is null statement?
If we don’t want some of the fields not to serialize how to do that?
Explain different ways of creating a thread?
Does java allow overriding static methods ?
What is variable length arguments in java?
Why arraylist is not synchronized in java example?
What are the four corner stones of oop?
Does unicode support all languages?
How would overload a function based on return type?
How would you dynamically allocate memory to an array?
Can we call thread start () twice?
What is the exact difference in between Unicast and Multicast object? Where will it be used?
what are synchronized methods and synchronized statements? : Java thread