What is different in method overloading and method overriding | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 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