what is difference between method overloading (compile-time polymorphism) and method overriding(Runtime polymorphism) in relation to inheritance? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

what is difference between method overloading (compile-time polymorphism) and method overriding(Runtime polymorphism) in relation to inheritance?

another what way to see the question, is compile-time polymorphism possible without inheritance?

1st Oct 2016, 9:19 AM
Ibrahim Ismail Ameer
Ibrahim Ismail Ameer - avatar
7 Answers
0
The process of defining a method with same name is called method overloading. When we define a method in a derived class where name and the argument exactly same with in parent class, then we already override method in parent class. More detail in: http://javabasictoadvanced.blogspot.co.id/2016/07/method-overloading.html http://javabasictoadvanced.blogspot.co.id/2016/08/method-overriding.html
1st Oct 2016, 9:45 AM
Aula Muttaqin
Aula Muttaqin - avatar
0
if method can't be inherited it can't be overridden and vice versa for overloading
12th Oct 2016, 7:47 PM
abdallah
abdallah - avatar
0
in overloading either inheritance or not method could be overloading
12th Oct 2016, 7:52 PM
abdallah
abdallah - avatar
0
Method Overriding - Overriding requires inheritance, because if same method names and same parameters are used in one class it will give Error. Method Overloading - Can be done without need of Inheritance, but Inheritance may or may not be used, its totally upto you!
20th Nov 2016, 9:22 AM
Danish Khan
Danish Khan - avatar
0
Overriden - it can perform with 2 classes Overloading- it can perform only within a class
1st Dec 2016, 3:53 AM
Madhumitha Dayanandan
Madhumitha Dayanandan - avatar
0
void meth2 (){...} in classe c1 and void math2 (int a){...} in classe c2 extends c1 is it overloading or over riding??
2nd Dec 2016, 5:58 PM
mar oua
mar oua - avatar
- 1
overloading is when your class A extends another class , lets say B , class A extends B{...} and B has method public void eatSomething() in class A you can create the same method but with another body. in this case u overload the mehod. notice that it is important to have the same parameters into () and one method can not be viid and another lets say String . overriding is when u rewrite a method in thr same class but with another arguments. for example you can have 3 constructors in the same class new constr() new constr(arg1) new constr(arg1,arg2)
1st Oct 2016, 4:13 PM
George Obretin
George Obretin - avatar