Distinguish method overloading and method overriding

Answers were Sorted based on User's Feedback



Distinguish method overloading and method overriding..

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

Distinguish method overloading and method overriding..

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

Distinguish method overloading and method overriding..

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

Distinguish method overloading and method overriding..

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

Post New Answer

More Core Java Interview Questions

State the merge-sort principle and its time complexity.

0 Answers   Akamai Technologies,


What is core java used for?

0 Answers  


Can we call a non-static method from inside a static method?

0 Answers  


How can a gui component handle its own events?

0 Answers  


Why ArrayList class is not a synchronized class and why it is not a thread safe class? explain

1 Answers  






What is the reason that multiple inheritance is not possible in java??

1 Answers  


What is nested loop? What is dangling else condition in it?

0 Answers   Ericsson,


What is the difference between jsp and servlet?

6 Answers   Symphony,


Which variables are stored in heap?

0 Answers  


What is the difference between stringbuffer and stringbuilder class?

0 Answers  


what is web.xml?and its use?

7 Answers   CTS,


Can a class extend more than one class?

0 Answers  


Categories