Qus:- What is the difference between this() and super() in Java?


5/14/2019 2:09:43 PM

Deepika Mourya

7 Answers

New Answer


this refers to the current instance of the class and super refers to the constructor of the parent class


this keyword: The this keyword can be used inside any method to refer to current object. For example: Box(double length,double breadth,double height) { this.length=length; this.breadth=breadth; this.height=height; }


Super refers to the superclass that a class extends. this refers to the current instance of a class.




super() is used to call the Base class's(Parent class's) constructor. this() can be passed as an argument in the method call and that is Method or constructor is being invoked.


As far as I see, you are posting these questions every day to earn sololearn badges. You already know these concepts and are still posting questions. It's more or less equivalent to spamming. Please don't spam Deepika Mourya