Total Page Preview:   000000000100

What is hierarchical inheritance in OOPS in English and Hindi


Hierarchical inheritance in OOPS in English:

Hierarchical inheritance is a type of inheritance in object-oriented programming where a single class serves as the superclass for multiple subclasses. Each subclass inherits the properties and methods of the superclass, but can also have its own unique properties and methods.

Here's an example of hierarchical inheritance in C#:

In this example, Animal is the superclass, and Dog and Cat are the subclasses. Both Dog and Cat inherit the Eat() method from Animal, but they also have their own unique methods, Bark() and Meow(), respectively.
So, you can create instances of the Dog and Cat classes, and call their methods like this:
Hierarchical inheritance in OOPS in Hindi:
Hierarchical inheritance ek object-oriented programming (OOP) concept hai, jisme ek class dusri class ko extend karti hai, aur phir dusri class bhi ek aur class ko extend karti hai, jis se ek tree-like hierarchy create hota hai jaha multiple derived classes, ek base class ko extend karte hain.
Isme base class me ek set of properties aur methods define kiye jate hai, jinhe derived classes ko extend kiya ja sakta hai. Derived classes me base class ke properties aur methods ko override kiya ja sakta hai aur new properties aur methods bhi add kiye ja sakte hai. Hierarchical inheritance ka use karke, derived classes me base class ke methods aur properties ka reuse kiya ja sakta hai.
Yaha ek C# example hai jisme hierarchical inheritance ka use kiya gaya hai:
Is example me humne Animal class ko create kiya hai, jisme ek method Eat() hai. Uske baad humne Cat class ko Animal class ko extend karne ke liye create kiya hai, jisme ek method Meow() hai. Isi tarah humne Dog class ko bhi Animal class ko extend karne ke liye create kiya hai, jisme ek method Bark() hai.
Main() method me humne Cat aur Dog class ke objects create kiye hai aur Eat(), Meow(), aur Bark() method ko call kiya hai. Hum dekh sakte hai ki Cat aur Dog class dono Animal class ko extend kar rahe hai aur Eat() method ko call kar rahe hai. Is tarah se hum hierarchical inheritance ka use karke ek class ke functionality ko dusri class me extend kar sakte hai.

Thank You

About Author

Brijesh Kumar

Database Developer

I have more then 6 years Experience in Microsoft Technologies - SQL Server Database, ETL Azure Cloud - Azure SQL Database, CosmosDB, Azure Data Factory, PowerBI, Web Job, Azure Function, Azure Storage, Web Apps, Powershall and Database Migration On-Premise to Azure Cloud.
LinkedIn :





Facebook User: