We Offer 100% Job Guarantee Courses (Any Degree / Diploma Candidates / Year GAP / Non-IT / Any Passed Outs). Placement Records
Hire Talent (HR):+91-9707 240 250

General

Super keyword 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 !
Besant Technologies WhatsApp