Java – class inheritance | superclass and subclass

Java – class inheritance | superclass and subclass

In Java a class can inherit another class. The inherited class is called Superclass and the class that inherits another class it is called subclass. syntax: puplic class subclassName extends superclassName{ additional fields and methods or method overriding } The subclass should only declare new fields, implement new methods or override superclass methods. All the variables and methods of the superclass are inherited automatically. As you see on the example above, the subclass’s constructor called the superclass constructor using the super keyword. This is important. The subclass must initialize the…

Java – class inheritance | superclass and subclass Read More