Distinguish method overloading and method overriding
Answers were Sorted based on User's Feedback
Answer / sagar.rds
Method overloading is compile time polymorphism and method
over riding is Runtime polymorphism.Method oveloading is
having same name and different parameters and different
return type also.Method overriding same name with same
parameters and having same return type
| Is This Answer Correct ? | 18 Yes | 3 No |
Answer / umanath
Method overloading is compile time polymorphism and method
overriding is Runtime polymorphism.
Method overloading is having same name and different
parameters and different return type also. But same type and
same no:of parameters but different return type is not allowed.
Error while compile: type methodname(type name) is already
defined in classname.
Method overriding same name with same parameters and having
same return type in different class while inheritance is
applied.
Try this following program: this will throw a error while
compiling.....
class OverloadDemo {
int test(int x) {
return x*x;
}
long test(int a) {
long l = a*a*a;
return l;
}
double test(double a) {
return a*a;
}
}
| Is This Answer Correct ? | 4 Yes | 1 No |
Answer / sushila
method overloading is method name should be same but
signature should be different.
method overriding is method name and arguments should be
same but return type will be same or wider.
| Is This Answer Correct ? | 0 Yes | 1 No |
Answer / sarbbottam bandyopadhyay
For method overloading the return type have to be same. Only the number of argument or type of argument or both will be different. But return type have to be the same.
| Is This Answer Correct ? | 0 Yes | 3 No |
if a java file without any source code is valid java file?
What are some alternatives to inheritance?
What is array in java?
Explain about static nested classes in java?
Write a program to print fibonacci series up to count 10.
when a servlet sends request for first time it uses the follwing methods a)init b)doget() c)dopost() d)service
how to handle a singleton service locator. when multiple threads are trying to get the singleton object in same time
What is temp in java?
what do you mean by classloader?
What is the common usage of serialization? What exceptions occur during serialization?
What is an immutable class? How to create an immutable class?
what is the role of xml in core java?? and how we can use it?? can somebody give a sample program with explanation and from where i can read more about xml?????
0 Answers HCL, SAP Labs, Vital Soft,