Distinguish method overloading and method overriding

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can Exception handling we can handle multiple catch blocks?

841


What do you understand by the term polymorphism?

832


What is the meaning of flag day?

756


What do the thread?class methods run() and start() do?

786


Why do we override tostring method in java?

689


Do you know why doesn't the java library use a randomized version of quicksort?

754


Convert Binary tree to linked list.

837


Have you ever used hashtable and dictionary?

802


Explain the difference between hashmap and hashtable in java?

718


Is hashmap thread safe?

773


How many return statement are allowed in a function?

660


Can we create a constructor in abstract class?

767


What is methods and methodology?

791


Is array serializable java?

730


What is main method?

780