Want to make creations as awesome as this one?

Transcript

START

InHeritence

INHERITENCE

1

Inheritence

In OOP, computer programs are designed in such a way where everything is an object that interact with one another. Inheritance is one such concept where the properties of one class can be inherited by the other. It helps to reuse the code and establish a relationship between different classes.

As we can see in the image, a child inherits the properties from his father. Similarly, in Java, there are two classes: 1. Parent class ( Super or Base class) 2. Child class (Subclass or Derived class )

Classification

Classification of inheritance into four groups

Hybrid

02

04

MULTI level

03

Single

01

Hierarchical

One class inherits the properties of another. It enables a derived class to inherit the properties and behavior from a single parent class. This will in turn enable code re usability as well as add new features to the existing code.

When a class is derived from a class which is also derived from another class, i.e. a class having more than one parent class but at different levels, such type of inheritance is called Multilevel Inheritance.

When a class has more than one child classes (sub classes) or in other words, more than one child classes have the same parent class

It is a combination of multiple inheritance and multilevel inheritance. Since multiple inheritance is not supported in Java as it leads to ambiguity, so this type of inheritance can only be achieved through the use of the interfaces.

This is all about

Inheritence