Don't let the Lockdown slow you Down - Enroll Now and Get 3 Course at 24,999/- Only. Explore Now!

General

Super keywords in java

Super keyword in Java

Super keyword in Java

It’s a reference variable that is used to be referring immediate parent class objects. This concepts came from inheritance.

Super keyword used in the below forms

  • Super with Variables
  • Super with Methods
  • Super with Constructors

Super with Variables:

If parent and child class has same variable then this will be achieve using super keyword.

Example:

Super Keyword in Java

Output:

Super Keyword in Java Output

Super with Methods:

If parent and child class has same methods then this will be achieve using super keyword. suppose the below same method in both classes then it will be call as.

Example:

show(); // child class 
super.show(); // Parent Class 

Super with Constructors:

Using super keyword we can call parent class constructor also and it can be default and parameterized.

Example:

Super with Constructor

Output:

Super with Constructor Output

Are you Interested in Java Course? – Click Here !
Scroll Up
Besant Technologies WhatsApp