What is Inheritance?
In this lesson, you will be introduced to Inheritance, a powerful concept in object-oriented programming.
We'll cover the following
Now that you are familiar with the concepts of objects and classes, let’s discuss inheritance which is another key concept in object-oriented programming.
Definition
Inheritance provides a way to create a new class from an existing class. The new class is a specialized version of the existing class such that it inherits all the non-private fields (variables) and methods of the existing class. The existing class is used as a starting point or as a base to create the new class.
The IS A Relationship
After reading the above definition, the next question that comes to mind is, when do we use inheritance? Wherever we come across an IS A relationship between classes, we can use inheritance.
Get hands-on with 1400+ tech skills courses.