+ 2

What is different in method overloading and method overriding

Question in Java

22nd Sep 2017, 11:48 AM
Saïd Kamal
Saïd Kamal - avatar
2 Respostas
22nd Sep 2017, 3:08 PM
Nanda Balakrishnan
+ 5
method overloading is a method with the same name but different input arguments such as public int add(int a, int b){ return a + b; } public int add(int a, int b, int c){ return a+b + c; } method overriding is when you basically replace the code for a method without removing the original code. So it can be specific to a given class or whatever. a good and common example of this is the toString method.
22nd Sep 2017, 11:59 AM
Ryan Ward
Ryan Ward - avatar