To apply inheritance from a superclass to a subclass in Java, you use the extends keyword. The basic syntax of inheriting from a superclass to a subclass:
public class <subclass> extends <superclass> {…}
When inheritance is applied to classes, all attributes and methods from the superclass exists automatically in the subclass even without physical implementation. Even though it exists, it will still follow the scopes of modifier access.
If an attribute or method is declared as private in the superclass, since it can only be accessed in the same class, the class inheriting it cannot access it at any point of its own implementation.
The scope of the keyword protected is that it can be accessed by the same class, it's subclasses, and the other class in the same package that the class is in. In UML class diagram, it is denoted by the symbol, #.
Thepublic access modifier can be accessed anywhere, meanwhile private access modifier can only be accessed within the class itself, not to its subclass and other classes it is packaged with.
The super keyword can be used like the this keyword to access an attribute or method from a superclass.
When invoking the constructor of the superclass when implementing the constructor of the subclass, it should be placed on the topmost part of the implementation.
If a method defined in a subclass such that the name, return type, and argument list exactly match those of a method in the superclass, then the new method is said to override the old one
In design, overriding methods from a superclass is not mandatory. It is only executed when implementation of a method to a subclass should be changed because either new attributes or procedure is integrated leading to a revised implementation of that superclass method.