These two terms are very confusing for developers. Why? Because they look similar. Let's understand these two terms. We will see the actual code.
Method overloading: First we will see an example then I will explain it to you. Here is an example .
If you have looked at the example I have shared then you will notice that the two methods have the same name. But they accept different data types . This is called method overloading. If you put a double value then the program will automatically call the method which accepts a double value .
Method overrding: Here also we will see an example then I will explain it to you. Have a look at the example.
Alright you have seen the example. What is happening here is that we are rewriting the superclass method makesound().
This is known as method overriding.
So you have learned method overriding and method overloading. Now I have made one question for you to test you. You have to predict the output.
What would be the out of the following code?