Difference between overloading and overriding | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

Difference between overloading and overriding

Overloading and overriding

9th Dec 2019, 2:03 PM
Chandu187
Chandu187 - avatar
5 Answers
0
Overloading is in a class Where override is in two different class
11th Dec 2019, 8:53 AM
Halikar Swapnil Apparao
Halikar Swapnil Apparao - avatar
+ 4
These concepts may also be defined in the tutorials.
11th Dec 2019, 10:03 AM
Sonic
Sonic - avatar
+ 3
What language do you use ? I use c#. Overloading : Being able to call a method with the same name with different parameters https://code.sololearn.com/cmWLZrb9Tddw/#cs Overriding : Change the behaviour of a method in the base-class in a derived class https://code.sololearn.com/c7P1Q7lSmIWU/#cs
9th Dec 2019, 2:19 PM
sneeze
sneeze - avatar
+ 3
HABIB KHAN please don't spam.
11th Dec 2019, 10:03 AM
Sonic
Sonic - avatar
+ 1
Hello, There are many differences between overloading and overriding. But the main difference is between these is for overloading you require one class while for overriding you require two classes. Following is the simple example of overloading and overriding. class OverloadingExample { static int add(int a,int b){return a+b;} static int add(int a,int b,int c){return a+b+c;} } class Animal { void eat() { System.out.println("eating..."); } } class Dog extends Animal { void eat() { System.out.println("eating bread..."); } }
10th Dec 2019, 5:22 AM
Ishan Shah
Ishan Shah - avatar