What is Overriding?
Answer:
To override a method, a subclass of the class that originally declared the method must declare a method with the same name, return type (or a subclass of that return type), and same parameterlist.
The definition of the method overriding is: · Must have same method name. · Must have same data type. · Must have same argument list.
Overriding a method means that replacing a method functionality in child class. To imply overriding functionality we need parent and child classes. In the child class you define the same method signature as one defined in the parent class.
No comments:
Post a Comment