Home » java-tutorial » Inheritance in java

Newly Updated Posts

Inheritance in java

Inheritance: It is a feature in Oops concept where a class inherits all the features of another class. When a class inherits the methods and global variable of another class it is not able to perform the action on the defined structure of another class.

The reason for introducing the concept of inheritance in java, is re-usability now the same method and field defined in one class can be used by another class and can also add additional methods,variable etc to it.

Important terminology of inheritance in java:

  • Sub Class : The class which inherits the methods, fields and variable of another class is known as sub class. Sub class can also create its own methods,variable and fields.
  • Super Class : The class from which the sub class inherits all the features and re-use or access the defined methods, fields and variables is Super Class.
  • Re-usability : its a approach to re-use the defined methods, fields etc, which we need on current class gets from another class.

Syntax used for inheritance:

class subClass extends superClass {