Friday, 17 April 2020

SE - 56 - Difference between super and super()

Differences :


SUPERSUPER()
The super keyword in JAVA is a reference variable that is used to refer parent class objects.The super() in JAVA is a reference variable that is used to refer parent class constructors.
super can be used to call parent class’ variables and methods.super() can be used to call parent class’ constructors only.
The variables and methods to be called through super keyword can be done at any time,Call to super() must be first statement in Derived Class constructor.
If one does not explicitly invoke a super class variables or methods, by using super keyword, then nothing happensIf a constructor does not explicitly invoke a super class constructor by using super(), the Java compiler automatically inserts a call to the no-argument constructor of the super class.

No comments:

Post a Comment