Page 354 - CA_Blue( J )_Class10
P. 354
Vehicle
Motor Driven Pull_Push Vehicle
Car Cycle
While developing a code, there may be a requirement to create more than one class. Under such situation, we may
share the data members and methods of one class with another class. This helps to reduce the coding as well as the
complexity of the programs. This is the concept of reusability.
Inheritance in Java is the method which allows one class to inherit the properties (data members and member
methods) of another class. The class from which the data is inherited is called base class or superclass and the class
which inherits the data is called derived class or subclass.
Types of inheritance in Java are:
• Single Inheritance
• Multiple Inheritance
• Multilevel Inheritance
• Hierarchical Inheritance
• Hybrid Inheritance
Let us study about them in detail.
14.4.1 Single Inheritance class super
When a subclass is inherited from one superclass, then the type of inheritance is termed
as single inheritance.
class sub
14.4.2 Multiple Inheritance
When a subclass is inherited from more than one superclass, then the type of inheritance is termed as multiple
inheritance.
class super1 class super2
class sub
Note: Java doesn’t support Multiple Inheritance.
14.4.3 Multilevel Inheritance
When a subclass is inherited from another subclass which is further derived from a class super
superclass, then the type of inheritance is termed as multilevel inheritance.
14.4.4 Hierarchical Inheritance
When more than one derives class is inherited from a base class, then the type of inheritance class sub1
is termed as Hierarchical inheritance.
class sub2
352352 Touchpad Computer Applications-X

