☕ Java Beginner

What is the super keyword in Java?

Answer

The super keyword refers to the parent (superclass) of the current class. It has three uses: accessing an overridden method from the parent class (super.methodName()), accessing a parent class field that is hidden by a subclass field (super.fieldName), and calling the parent class constructor (super(args) — must be the first statement in the subclass constructor). Every constructor implicitly calls super() if you do not explicitly call it, which chains all the way up to the Object constructor. super cannot be used in static contexts.