+ 2
Overriding or Overloading
In these classes makeSound method is Overrided or Overloaded? class Animal { public void makeSound(Animal a) { System.out.println("Grr..."); } } class Cat extends Animal { public void makeSound(Cat a) { System.out.println("Meow"); } }
6 Respuestas
+ 4
overridden method.
you can say ...
any two methods with same (name,parameters and return type) we will call it overridden method.
if any deference in parameters or return type but with same name, it means overloaded method.
+ 3
The Cat class it's overriding the method makeSound inherited from class Animal. In this case changes de text "Grr..." to "Meow" from class Animal that is printed when the method is called.
+ 2
simple overriding
+ 2
Thanks sir Melissa Melik
+ 1
here is an example that you may want to check to see difference or understand the meanings of overriding and overloading https://code.sololearn.com/c0awDMpDLukF/?ref=app
0
Overriding using covariant returntypes