Method Overriding
Last updated
Last updated
When a Child class redefines the method of its Parent class then it is called Method Overriding
Overriding is done so that a child class can give its own implementation to the method which is already provided by the parent class.
The number and data type of function’s argument must match while overriding the method
Here in the child class , the return type and the argument datatype of the method is changed from "int" to "double" , so the compiler shows an error
You can visualise method overriding like below -