Core Java Interview Questions-Inheritance

This Core Java Interview Questions-Inheritance page provides core java interview questions and answers on Inheritance including what is inheritance, types of inheritance, multiple inheritance, hierarchical inheritance, java.lang.Object class, parent class instantiation in java.

What is inheritance?
Defining an object using the functionality of existing object.

Why inheritance keyword name is “extends”?
“extends” means enhancement of Object by adding new functionality and updating existing functionality.

What is the advantage of Inheritance?
The main advantage of inheritance is “code re-usability”.

Does java support all types of Inheritance?
Java supports Single, Multi-level and Hierarchical inheritances only by using classes.
Support Multiple & Hybrid inheritances using interfaces.

What is the super class of all java classes?
The object class is the super class of all.

How to access Parent object functionality from Child class?
In Inheritance, we always need to create an object for Child class only.
By using Child object address, we can access both Parent and Child objects functionality.

Can we create an object for Parent class in inheritance?
Yes allowed but Child class will not get instantiated.

How Parent class gets instantiate in Inheritance?
In the process of Child Object creation, JVM instantiates Parent object first.

How JVM invokes Parent class constructor to instantiate?
Using super() method from Child class constructor.

How to analyze whether JVM instantiating the class or not?
By defining a default constructor inside Parent class.
In the process of object creation either by JVM(implicitly) or by Programmer(explicitly), constructor
calling is mandatory.

What is hierarchical inheritance?
Sharing properties to more than one class which are extended.
Allowing many classes to update the functionality of the xisting object.

>Core Java Interview Questions-Super Keyword<

Share this