What is Method Overriding?
Ask by Anonymous User
Updated 20 Sep 2020
Method overriding, in object oriented programming, is a language feature that allows a subclass or child class to provide a specific implementation of a method that is already provided by one of its superclasses or parent classes. The implementation in the subclass overrides (replaces) the implementation in the superclass by providing a method that has same name, same parameters or signature, and same return type as the method in the parent class.If subclass (child class) has the same method as declared in the parent class, it is known as method overriding in java.
The new method definition must have the same method signature and return type.
Clas A
{
Virtual void sum (int a)
{
}
}
Class B:A
{
public overrid void sum (int a)
{
}
}