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

When will you define a method as static?

847


Who found java?

794


Tell us something about an iterator.

743


Differentiate between a constructor and a method? Can we mark constructors final?

977


What is visibility mode?

750


What is the exception hierarchy in java?

761


How do I get the | symbol on my keyboard?

809


Explain about public and private access specifiers?

800


How will you invoke any external process in java?

878


What is function and method in java?

755


Explain access specifiers?

930


how to split string in java?

890


Give a practical example of singleton class usage?

806


Can one thread block the other thread?

822


Is java call by value?

838