Differentiating the Members If a class is inheriting the properties of another class. In some cases a subclass will mask non-private superclass fields by declaring same-named fields. Inheritance represents the IS-A relationship which is also known as a parent-child relationship.
What all can be done in a Subclass? And if the members of the superclass have the names same as the sub class, to differentiate these variables we use super keyword as shown below.
We can write a new static method in the subclass that has the same signature as the one in the superclass, thus hiding it. When a Class extends another class it inherits all non-private members including fields and methods.
We are supposed to open two different account types, one for saving and another for checking also known as current. Constructors are not members, so they are not inherited by subclasses, but the constructor of the superclass can be invoked from the subclass.
The more-specific category is a kind of the more-generic category. It is also called a derived class, extended class, or child class.