Core Java Interview Questions-Super Keyword
This Core Java Interview Questions-Super Keyword page provides core java interview questions and answers about the super keyword in java inheritance including the importance of super keyword, what is super() method, constructor chaining in parent-child relationships and many more questions with appropriate answers.
What is super?
It is a keyword.
It is pre defined non static variable in java.
What is the use of “super” keyword?
User to access Parent class functionality from Child class.
In which context, we use super keyword?
It must be used only in non-static context.
Does super keyword hold any value?
No, it is just an accessory and it doesn’t hold any address.
What is super() method?
Used to access Parent class constructor explicitly from the Child class.
Can we use super() anywhere inside java class?
It must be used only in Child class constructor.
What is the use of super() method?
Used to initialize Parent class Object in the process of Child object creation.
How to access super() method?
From the first statement of child class constructor.
Can we connect more than one constructor from the current constructor?
Not allowed, call to this() and super() must be the first statements.
What is constructor chaining?
Connecting constructors either in the same class or in parent-child relation.
Can we print the address of Parent class?
It Parent-Child object creation process, Parent will not get separate memory allocation.