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

What are the benefits of operations?

0 Answers  


I have a class which is abstract which contains only the abstract methods. This is similar to an interface. Then, if i have given a choice to choose one of them. Which one i have to choose and why?

4 Answers  


Will the jvm load the package twice at runtime?

0 Answers  


What is a flag and how does it work?

0 Answers  


How to display all the prime numbers between 1 and 100

0 Answers  


What is a methodologist?

0 Answers  


You can create a string object as string str = “abc”; why cant a button object be created as button bt = “abc”;? Explain

0 Answers  


Hai friends I am MCA 2006 passout. Spend time in 1 yr for teacing and 5 months in small s/w firm. worked in 4 or 5 months in few places. Presently I am writing bank exams. I want to get back to IT sector. Are there any possibilities. any growth prospects?. I am having some knowledge in core and advanced java. I am so desperate. Any suggestions thanks in advance. u can write to my mail mahidestiny@gmail.com

4 Answers  


What is ‘has a’’ relationship in java?

0 Answers  


What is a map? What are the implementations of map?

0 Answers  


What is deserialization and how do we do deserialization?

3 Answers   Synechron,


Explain about GridBag Layout?

1 Answers  


Categories