+ 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?
7 Antworten
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
0
if method can't be inherited it can't be overridden and vice versa for overloading
0
in overloading either inheritance or not method could be overloading
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!
0
Overriden - it can perform with 2 classes
Overloading- it can perform only within a class
0
void meth2 (){...} in classe c1 and void math2 (int a){...} in classe c2 extends c1 is it overloading or over riding??
- 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)