Difference Between this and super in Java4 Aug 2025 | 7 min read In Java, the keywords "super" and "this" are essential for interacting with classes and objects. In addition to referring class members, they assist in managing inheritance. Java also provides the this() and super() constructors, which are used in the context of constructors. this keyword and this() constructorthis keywordIt is a reserved keyword in Java that refers to the current instance of the class. It is a reference variable through which the method is called. Other uses of this keyword are:
this() ConstructorIn Java, this() is a special constructor call used within another constructor of the same class to invoke a different constructor. It helps with constructor chaining, which allows us to reuse initialization logic and reduce redundancy.
Example: Use of this Keyword and this() ConstructorExampleCompile and RunOutput: We are inside the parameterized constructor. The value of y = 10 We are inside the default constructor. The value of x = 5 Inside Main Usages of this Keyword
super Keyword and super() Constructorsuper KeywordA reserved keyword used to call the base class method or variable is known as a super keyword. We cannot use the super keyword as an identifier. The super keyword is not only used to refer to the base class instance but also to static members. Note: The super keyword cannot be used to access static methods or variables directly. Static context is handled differently.super() Constructorsuper() is a special call used inside a subclass constructor to invoke the constructor of its superclass. It ensures that the superclass is properly initialized before the subclass adds its own features. Always the first statement in a subclass constructor-Java would not allow it anywhere else. Note: If we do not explicitly write super() constructor, the JVM automatically inserts a call to the no-argument constructor of the superclass-unless we call a specific one with arguments.
Example: Use of the super Keyword and super() ConstructorExampleCompile and RunOutput: The cat is of color white The cat is of color Brown The eyes of the cat are blue. Inside Main Explanation In the above example, we have defined Animal, Cat, and Main class. The Cat class extends the Animal class, and the Main class extends the Cat class. Inside the Main class, we have defined the Main class constructor as Main(). Inside the constructor, we have called the super() class constructor, which calls the constructor of its parent class, i.e., Cat. When the second statement executes, the program's flow jumps to the Animal class to access the values of its data members. After accessing it, the flow returns to the Cat class constructor and prints the result. After that, the last statement executes and prints the value of the variables of the current class. After execution of the last statement of the Cat class, the flow comes back to the constructor of the class Main and executes the remaining statements. After completing the execution of the Main method, the flow comes back to the main() method and executes the remaining statements. Note: In order to use the super(), we have to make sure that it is the first statement in the constructor of a class. We can use it to refer only to the parent class constructor.Usages of the super Keyword
Differences Between this and super KeywordThe following table describes the key difference between this and super:
Differences Between this() and super() Constructor
Java this and super MCQs1. In Java, this keyword refers to_______?
Answer: 2) Explanation: It is a reserved keyword in Java that is used to refer to the current class object. It is a reference variable through which the method is called. 2. From the following statements, select the correct one about this() constructor call.
Answer: 3) Explanation: The correct statement about this() constructor call is that it is used to invoke another constructor within the same class. It must be the first line of the constructor where it's used. 3. In Java, the super keyword refers to_______?
Answer: 3) Explanation: In Java, the super keyword refers to the superclass of the current object. 4. Which of the following is not a valid usage of this keyword?
Answer: 4) Explanation: Referring to instance variables of the current class is a valid usage of this keyword in Java. 5. Which keyword is used to call the constructor of the superclass in a subclass constructor?
Answer: 1) Explanation: The super keyword is used to call the constructor of the superclass in a subclass constructor. This ensures that the subclass constructor properly initializes the inherited members from the superclass. Next TopicJava-copy-array |
We request you to subscribe our newsletter for upcoming updates.

We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India