Use of super keyword in Java

The super keyword is another important one. This is a reference variable that is used to call the immediate parent class. This keyword is expensive when we talk about Inheritance and Polymorphism. There are three uses of the super keyword. 
  1. super with variables
  2. super with constructors
  3. super with method overriding 

Super with variables

  • If you use super with instance variables, it will refer to the variables of the immediate parent class.
  • Look at the following example.

Super with constructors

  • We can use the super keyword to invoke the constructor of the immediate parent class 
  • Once you instantiate a class, the compiler calls the default constructor of that class.

Super with method overriding

  • If you want to call methods in the parent class, you can use super keyword.
  • In overriding, it will call the child class method instead of the parent class.
  • Look at the following example.

Use of super keyword in Java Use of super keyword in Java Reviewed by Ravi Yasas on 12:41 PM Rating: 5


  1. It’s amazing in support of me to truly have a web site that is valuable meant for my knowledge.

  2. The QSR, or quoted search result, on the keyword tool is the number of competing websites ranked in Google looking for the first page ranking for that exact keyword.keyword combination tool

  3. I’m going to read this. I’ll be sure to come back. thanks for sharing. and also This article gives the light in which we can observe the reality. this is very nice one and gives indepth information. thanks for this nice article...


Powered by Blogger.