Please enable JavaScript.
Coggle requires JavaScript to display documents.
INHERITANCE - Coggle Diagram
INHERITANCE
TYPES
Mutiple
In Multilevel Inheritance, a derived class will be inheriting a base class, and as well as the derived class also acts as the base class for other classes
-
Multilevel
Multilevel inheritance is when a class inherits properties from another class that has already inherited properties from another class. This creates a hierarchy where each level inherits properties from the level above it.
-
Single
In single inheritance, subclasses inherit the features of one superclass. In the image below, class A serves as a base class for the derived class B.
-
Hybrid
It is a mix of two or more of the above types of inheritance. Since Java doesn’t support multiple inheritances with classes, hybrid inheritance involving multiple inheritance is also not possible with classes.
-
-
USES
Code Reusability: The code written in the Superclass is common to all subclasses. Child classes can directly use the parent class code.
Method Overriding: Method Overriding is achievable only through Inheritance. It is one of the ways by which Java achieves Run Time Polymorphism
Abstraction: The concept of abstract where we do not have to provide all details is achieved through inheritance. Abstraction only shows the functionality to the user.
TERMS
Sub Class/Child Class: The class that inherits the other class is known as a subclass(or a derived class, extended class, or child class). The subclass can add its own fields and methods in addition to the superclass fields and methods.
Super Class/Parent Class: The class whose features are inherited is known as a superclass(or a base class or a parent class).
Reusability: Inheritance supports the concept of “reusability”, i.e. when we want to create a new class and there is already a class that includes some of the code that we want, we can derive our new class from the existing class. By doing this, we are reusing the fields and methods of the existing class
Class: Class is a set of objects which shares common characteristics/ behavior and common properties/ attributes. Class is not a real-world entity. It is just a template or blueprint or prototype from which objects are created.
-
DEFENITION
Inheritance is the concept in OOPs in which one class inherits the attributes and methods of another class. The class whose properties and methods are inherited is known as the Parent class. And the class that inherits the properties from the parent class is the Child class.