0 votes
in JAVA by
What is the Inheritance?

1 Answer

0 votes
by

Inheritance is a mechanism by which one object acquires all the properties and behavior of another object of another class. It is used for Code Reusability and Method Overriding. The idea behind inheritance in Java is that you can create new classes that are built upon existing classes. When you inherit from an existing class, you can reuse methods and fields of the parent class. Moreover, you can add new methods and fields in your current class also. Inheritance represents the IS-A relationship which is also known as a parent-child relationship.

There are five types of inheritance in Java.

Single-level inheritance

Multi-level inheritance

Multiple Inheritance

Hierarchical Inheritance

Hybrid Inheritance

Multiple inheritance is not supported in Java through class.

Related questions

0 votes
asked May 25, 2020 in JAVA by Robindeniel
0 votes
asked Feb 8, 2021 in JAVA by SakshiSharma
...