What is Inheritance in Java Simple Definition, Computer, The Clairifiers

What is Inheritance in JAVA?


Inheritance is the process by which one object acquires the properties of another object This property allows the creation of a new class that makes use of whatever an existing class has and defines additional properties. One of the benefits is that code once defined can be reused.

The class whose property is acquired is called a Base Class (Super Class, Main Class, Parent Class). The class in which the property of the base class is acquired is called a Derived Class (Extended Class, Sub Class, Child Class). We shall study this in detail later. We naturally view the world as made up of objects that are related to each other in a hierarchy. For example, consider your school. Each student in the school has attributes such as name age, age class, and behaviours such as eating, studying, etc. Study the figure given below.

Student class is the superclass with Senior School as a subclass; further 'Class X' is a subclass of Senior School. All objects of the 'Class X' class would have all the attributes and behaviours of the 'Student' Class.

Inheritance chart of the above example

Thank You So Much For Reading Till End!

Please share this post with your batch mates & whoever else needs this.

Post a Comment

Previous Post Next Post