Difference between this and super keyword in Java
The difference between this and super keyword in Java in tabular form is as follows:
|1.||“this” is a reference variable which contains current class objects.||“super” is a reference variable which contains immediate super class objects.|
|2.||Any member of the current class object from within an instance method or a constructor can be referred by using this keyword.||If the method overrides one of its super class’s method, the overridden method can be called through the use of super keyword.|
|3.||‘this’ keyword is used to call another constructor from within a constructor in the same class.||‘super’ keyword is used to call the super class’s constructor from within a constructor of the subclass.|
|4.||JVM never put automatically this() keyword like super() in Java.||By default JVM automatically put the super() keyword at first line inside the constructor.|
Hope that this tutorial has covered differences between super and this keyword in java. I hope that you will have understood all points explained in the tabular form.
Thanks for reading!!!
Next ⇒ Method overloading in Java⇐ PrevNext ⇒