0% found this document useful (0 votes)
84 views9 pages

Topics: Inheritance Inheritance Examples Java Support For Inheritance (Just Introduction) Types of Inheritance

The document discusses inheritance in object-oriented programming. It defines inheritance as a process where a class acquires properties of another class. It then provides examples of inheritance with classes like Animal, Man, Account, Checking. It also discusses the different types of inheritance like single, hierarchical, multi-level inheritance. Java support for inheritance is introduced.

Uploaded by

Shubhankar Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
84 views9 pages

Topics: Inheritance Inheritance Examples Java Support For Inheritance (Just Introduction) Types of Inheritance

The document discusses inheritance in object-oriented programming. It defines inheritance as a process where a class acquires properties of another class. It then provides examples of inheritance with classes like Animal, Man, Account, Checking. It also discusses the different types of inheritance like single, hierarchical, multi-level inheritance. Java support for inheritance is introduced.

Uploaded by

Shubhankar Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Topics

• Inheritance
• Inheritance Examples
• Java Support for Inheritance [Just
Introduction]
• Types of Inheritance

1 Object-Oriented Programming
Inheritance : Reusability
https://en.wikipedia.org/wiki/Inheritance_(object-oriented_programming)

• Process by which an object of one class


acquires properties of an object of other class
• Supports Reusability of code and data
• Inheritance Supports isA relationship
• The class whose properties are extended is
known as super class (in Java) or base class (in
C++) or parent class.
• The class which extends the properties of
super class is known as sub class (in Java) or
derived class (in C++) or child class

2 Object-Oriented Programming
Inheritance : Some Simple
Examples

Animal Super class

• Man isA Animal


Man Sub class

Account Super class


• Checking isA kind of
Account
Checking Sub class

Shape Super class


• Circle isA Type of
Shape Sub class
Circle
3 Object-Oriented Programming
Inheritance in Java
class Animal
{ <<Super Class>>

// Define the Baisc Properties of Every Animal Animal

} // End of class Animal


Man
class Man extends Animal
{ <<Sub Class>>
// Define specific details only for man

}// End of class Man

4 Object-Oriented Programming
Types of Inheritance

• Single Level Inheritance


• Hierarchical Inheritance
• Multi-Level Inheritance
• Multiple Inheritance

5 Object-Oriented Programming
Types of Inheritance : Single Level

Single Level Inheritance

class A
{
A ….
}// End of class A

class B extends A
B
{
…..
}// End of class B

6 Object-Oriented Programming
Types of Inheritance : Hierarchical

Hierarchical Level Inheritance


class X
{
….
}// End of class X
X
class A extends X
{
…..
}// End of class A
A B C
class B extends X
{
…..
}// End of class B

class C extends X
{
…..
}// End of class C
7 Object-Oriented Programming
Types of Inheritance : Multi-Level

Multi Level (Tree) Inheritance


class A
{
…..
A }// End of class A

class B extends A
{
…..
B }// End of class B

class C extends B
{
C …..
}// End of class C

8 Object-Oriented Programming
Types of Inheritance : Multiple

Multiple Inheritance

A B Not Supported in
Java Directly
class A
{
….
} // End of class A
class B
{
….
C }// End of class B
class C extends A, B Wrong
{
…. Not Allowed in
} // End of class C
Java
9 Object-Oriented Programming

You might also like