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

Which collection does not allow duplicates in java?

470


describe method overloading

539


Is main a function?

516


What’s the difference between unit, integration and functional testing?

616


What is the use of join method?

577






Assume a thread has lock on it, calling sleep() method on that thread will release the lock?

627


How to sort numbers in java without array?

532


What type of value does sizeof return?

543


Does printwriter create a file?

540


Explain an intermediate language?

509


Name container classes in java programming?

595


What is the use of keywords in java?

555


What are checked exceptions?

579


What is the static field modifier?

597


Can we use this () and super () in a method?

531