A subclass inherits the methods
from the super class and redefines it by filling it with its own instructions.
This is done by defining methods in the sub class that has the same name
arguments and same return type as the super class’s methods.
This is one method of achieving
polymorphism.
Methods
There are two types
Instance Methods
They work with the object instance. An instance method is called
by referring to an object name.
Ex:
Acc1.deposit
(200);
Class Methods
A class methods works on the
class not on the objects. It can be called by referring to class name. Class
methods are defining by using keyword static.
No comments:
Post a Comment