SlideShare a Scribd company logo
Topic :-Inheritance
Presented By:
Jinal Budheliya :170060107002
Nikit Dungarani :170060107008
Smit Savani :170060107053
Mayur Sharma :170060107054
Kaushik Sutariya :170060107059
Bhagwan Mahavir College of
Engineering and Technology
Guided By :Ms. Ridhdhi Naik
Subject :- .Net Technology(2160711)
Inheritance
 Inheritance is where one class (child class) inherits the properties of
another class (parent class).
 Inheritance is a mechanism of acquiring the features and behaviors
of a class by another class.
 The class whose members are inherited is called the base class, and
the class that inherits those members is called the derived class.
 Inheritance implements the IS-A relationship.
 Example
• “She had inherited the beauty of her mother”
Why Inheritance?
 Advantages of Inheritance
• Reduce code redundancy
• Provides code reusability
• Reduces source code size and improves code readability
• Code is easy to manage and divided into parent and child classes
Disadvantages - Inheritance
 In Inheritance base class and child classes are tightly coupled.
Hence If you change the code of parent class, it will get affects to
the all the child classes.
 In class hierarchy many data members remain unused and the
memory allocated to them is not utilized.
 Hence affect performance of your program if you have not
implemented inheritance correctly.
Different Types of Inheritance
Single Inheritance
Multi-level Inheritance
Multiple Inheritance
Multipath Inheritance
Hierarchical Inheritance
Hybrid Inheritance
Single Inheritance
Single Inheritance
In single inheritance, a derived
class is created from a single
base class.
Class A (Base)
Class B (Derived)
Example - Single Inheritance
//Base Class
class Teacher
{
public void Teach()
{
Console.WriteLine("Teach");
}
}
//Derived Class
class Student : Teacher
{
public void Learn()
{
Console.WriteLine("Learn");
}
}
class Program
{
static void Main(string[] args)
{
Teacher d = new Teacher();
d.Teach();
Student s = new Student();
s.Learn();
s.Teach();
Console.ReadKey();
}
}
Multi-level Inheritance
Multi-level
Inheritance
In Multi-level inheritance, a
derived class is created from
another derived class.
Class A (Base)
Class B
Class C
Example – Multi-Level Inheritance
//Base Class
class Teacher
{
public void Teach()
{
Console.WriteLine("Teach");
}
}
//Base,Derived Class
class Student : Teacher
{
public void Learn()
{
Console.WriteLine("Learn");
}
}
//Derived Class
class SemFour : Student
{
public void FourthSem()
{
Console.WriteLine("Semester
Four Students");
}
}
class Program
{
static void Main(string[] args)
{
Teacher d = new Teacher();
d.Teach();
Student s = new Student();
s.Learn();
s.Teach();
SemFour Sem = new SemFour();
Sem.Learn();
Sem.Teach();
Sem.FourthSem();
Console.ReadKey();
}
}
Cont..
Output :
Multiple Inheritance
Multiple Inheritance
 In Multiple inheritance, a derived class is created from more than
one base class.
 This inheritance is not supported by .NET Languages like C#, F#
etc.
Class A (Base) Class B (Base)
Class C
Example – Multiple Inheritance
//Base Class
class Teacher
{
public void Teach()
{
Console.WriteLine("Teach");
}
}
//Base,Derived Class
class Student
{
public void Learn()
{
Console.WriteLine("Learn");
}
}
//Derived Class
class SemFour : Student , Teacher
{
public void FourthSem()
{
Console.WriteLine("Semester
Four Students");
}
}
Multipath Inheritance
Multipath Inheritance
 In Multipath inheritance, a derived class is created from another
derived classes and the same base class of another derived
classes.
 This inheritance is not supported by .NET Languages like C#, F#
etc.
Class A
Class B Class C
Class D
Example – Multipath Inheritance
Hierarchical Inheritance
Class A
Class C Class B
Class D Class E Class F Class G
Example – Hierarchical Inheritance
Hybrid Inheritance
Class A
Class C Class B
Class D Class E
Class F
Example – Hybrid Inheritance
Inheritance

More Related Content

Similar to Inheritance

Inheritance
InheritanceInheritance
Inheritance
SangeethaSasi1
 
INHERITANCE, POINTERS, VIRTUAL FUNCTIONS, POLYMORPHISM.pptx
INHERITANCE, POINTERS, VIRTUAL FUNCTIONS, POLYMORPHISM.pptxINHERITANCE, POINTERS, VIRTUAL FUNCTIONS, POLYMORPHISM.pptx
INHERITANCE, POINTERS, VIRTUAL FUNCTIONS, POLYMORPHISM.pptx
DeepasCSE
 
Inheritance
InheritanceInheritance
Inheritance
Pranali Chaudhari
 
20.2 Java inheritance
20.2 Java inheritance20.2 Java inheritance
20.2 Java inheritance
Intro C# Book
 
Inheritance : Extending Classes
Inheritance : Extending ClassesInheritance : Extending Classes
Inheritance : Extending Classes
Nilesh Dalvi
 
29csharp
29csharp29csharp
29csharp
Sireesh K
 
29c
29c29c
inheritance in C++
inheritance in C++inheritance in C++
inheritance in C++
tayyaba nawaz
 
Inheritance
InheritanceInheritance
Inheritance
rajshreemuthiah
 
Inheritance_abstractclass_interface.pdf
Inheritance_abstractclass_interface.pdfInheritance_abstractclass_interface.pdf
Inheritance_abstractclass_interface.pdf
kshitijsaini9
 
OOP Assign No.03(AP).pdf
OOP Assign No.03(AP).pdfOOP Assign No.03(AP).pdf
OOP Assign No.03(AP).pdf
Anant240318
 
Inheritance In Java
Inheritance In JavaInheritance In Java
Inheritance In Java
Manish Sahu
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
RahulAnanda1
 
Inheritance used in java
Inheritance used in javaInheritance used in java
Inheritance used in java
TharuniDiddekunta
 
Inheritance and interface
Inheritance and interfaceInheritance and interface
Inheritance and interface
Shubham Sharma
 
Multiple inheritance
Multiple inheritanceMultiple inheritance
Multiple inheritance
zindadili
 
lecture 6.pdf
lecture 6.pdflecture 6.pdf
lecture 6.pdf
WaqarRaj1
 
INHERITANCE-Oopc ppt-ta4
INHERITANCE-Oopc ppt-ta4INHERITANCE-Oopc ppt-ta4
INHERITANCE-Oopc ppt-ta4
Ashutosh Makwana
 
Chap-3 Inheritance.pptx
Chap-3 Inheritance.pptxChap-3 Inheritance.pptx
Chap-3 Inheritance.pptx
chetanpatilcp783
 
Inheritance
InheritanceInheritance
Inheritance
prabhat kumar
 

Similar to Inheritance (20)

Inheritance
InheritanceInheritance
Inheritance
 
INHERITANCE, POINTERS, VIRTUAL FUNCTIONS, POLYMORPHISM.pptx
INHERITANCE, POINTERS, VIRTUAL FUNCTIONS, POLYMORPHISM.pptxINHERITANCE, POINTERS, VIRTUAL FUNCTIONS, POLYMORPHISM.pptx
INHERITANCE, POINTERS, VIRTUAL FUNCTIONS, POLYMORPHISM.pptx
 
Inheritance
InheritanceInheritance
Inheritance
 
20.2 Java inheritance
20.2 Java inheritance20.2 Java inheritance
20.2 Java inheritance
 
Inheritance : Extending Classes
Inheritance : Extending ClassesInheritance : Extending Classes
Inheritance : Extending Classes
 
29csharp
29csharp29csharp
29csharp
 
29c
29c29c
29c
 
inheritance in C++
inheritance in C++inheritance in C++
inheritance in C++
 
Inheritance
InheritanceInheritance
Inheritance
 
Inheritance_abstractclass_interface.pdf
Inheritance_abstractclass_interface.pdfInheritance_abstractclass_interface.pdf
Inheritance_abstractclass_interface.pdf
 
OOP Assign No.03(AP).pdf
OOP Assign No.03(AP).pdfOOP Assign No.03(AP).pdf
OOP Assign No.03(AP).pdf
 
Inheritance In Java
Inheritance In JavaInheritance In Java
Inheritance In Java
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
 
Inheritance used in java
Inheritance used in javaInheritance used in java
Inheritance used in java
 
Inheritance and interface
Inheritance and interfaceInheritance and interface
Inheritance and interface
 
Multiple inheritance
Multiple inheritanceMultiple inheritance
Multiple inheritance
 
lecture 6.pdf
lecture 6.pdflecture 6.pdf
lecture 6.pdf
 
INHERITANCE-Oopc ppt-ta4
INHERITANCE-Oopc ppt-ta4INHERITANCE-Oopc ppt-ta4
INHERITANCE-Oopc ppt-ta4
 
Chap-3 Inheritance.pptx
Chap-3 Inheritance.pptxChap-3 Inheritance.pptx
Chap-3 Inheritance.pptx
 
Inheritance
InheritanceInheritance
Inheritance
 

Recently uploaded

The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
History of Stoke Newington
 
Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...
PsychoTech Services
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
PECB
 
Solutons Maths Escape Room Spatial .pptx
Solutons Maths Escape Room Spatial .pptxSolutons Maths Escape Room Spatial .pptx
Solutons Maths Escape Room Spatial .pptx
spdendr
 
How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience
Wahiba Chair Training & Consulting
 
math operations ued in python and all used
math operations ued in python and all usedmath operations ued in python and all used
math operations ued in python and all used
ssuser13ffe4
 
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Fajar Baskoro
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
adhitya5119
 
ZK on Polkadot zero knowledge proofs - sub0.pptx
ZK on Polkadot zero knowledge proofs - sub0.pptxZK on Polkadot zero knowledge proofs - sub0.pptx
ZK on Polkadot zero knowledge proofs - sub0.pptx
dot55audits
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
eBook.com.bd (প্রয়োজনীয় বাংলা বই)
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
mulvey2
 
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem studentsRHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
Himanshu Rai
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
Priyankaranawat4
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Excellence Foundation for South Sudan
 
Constructing Your Course Container for Effective Communication
Constructing Your Course Container for Effective CommunicationConstructing Your Course Container for Effective Communication
Constructing Your Course Container for Effective Communication
Chevonnese Chevers Whyte, MBA, B.Sc.
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
Nicholas Montgomery
 
IGCSE Biology Chapter 14- Reproduction in Plants.pdf
IGCSE Biology Chapter 14- Reproduction in Plants.pdfIGCSE Biology Chapter 14- Reproduction in Plants.pdf
IGCSE Biology Chapter 14- Reproduction in Plants.pdf
Amin Marwan
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
heathfieldcps1
 
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skillsspot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
haiqairshad
 
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptxNEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
iammrhaywood
 

Recently uploaded (20)

The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
 
Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
 
Solutons Maths Escape Room Spatial .pptx
Solutons Maths Escape Room Spatial .pptxSolutons Maths Escape Room Spatial .pptx
Solutons Maths Escape Room Spatial .pptx
 
How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience
 
math operations ued in python and all used
math operations ued in python and all usedmath operations ued in python and all used
math operations ued in python and all used
 
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
 
ZK on Polkadot zero knowledge proofs - sub0.pptx
ZK on Polkadot zero knowledge proofs - sub0.pptxZK on Polkadot zero knowledge proofs - sub0.pptx
ZK on Polkadot zero knowledge proofs - sub0.pptx
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
 
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem studentsRHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
 
Constructing Your Course Container for Effective Communication
Constructing Your Course Container for Effective CommunicationConstructing Your Course Container for Effective Communication
Constructing Your Course Container for Effective Communication
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
 
IGCSE Biology Chapter 14- Reproduction in Plants.pdf
IGCSE Biology Chapter 14- Reproduction in Plants.pdfIGCSE Biology Chapter 14- Reproduction in Plants.pdf
IGCSE Biology Chapter 14- Reproduction in Plants.pdf
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
 
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skillsspot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
 
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptxNEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
 

Inheritance

  • 1. Topic :-Inheritance Presented By: Jinal Budheliya :170060107002 Nikit Dungarani :170060107008 Smit Savani :170060107053 Mayur Sharma :170060107054 Kaushik Sutariya :170060107059 Bhagwan Mahavir College of Engineering and Technology Guided By :Ms. Ridhdhi Naik Subject :- .Net Technology(2160711)
  • 2. Inheritance  Inheritance is where one class (child class) inherits the properties of another class (parent class).  Inheritance is a mechanism of acquiring the features and behaviors of a class by another class.  The class whose members are inherited is called the base class, and the class that inherits those members is called the derived class.  Inheritance implements the IS-A relationship.  Example • “She had inherited the beauty of her mother”
  • 3. Why Inheritance?  Advantages of Inheritance • Reduce code redundancy • Provides code reusability • Reduces source code size and improves code readability • Code is easy to manage and divided into parent and child classes
  • 4. Disadvantages - Inheritance  In Inheritance base class and child classes are tightly coupled. Hence If you change the code of parent class, it will get affects to the all the child classes.  In class hierarchy many data members remain unused and the memory allocated to them is not utilized.  Hence affect performance of your program if you have not implemented inheritance correctly.
  • 5. Different Types of Inheritance Single Inheritance Multi-level Inheritance Multiple Inheritance Multipath Inheritance Hierarchical Inheritance Hybrid Inheritance
  • 6. Single Inheritance Single Inheritance In single inheritance, a derived class is created from a single base class. Class A (Base) Class B (Derived)
  • 7. Example - Single Inheritance //Base Class class Teacher { public void Teach() { Console.WriteLine("Teach"); } } //Derived Class class Student : Teacher { public void Learn() { Console.WriteLine("Learn"); } } class Program { static void Main(string[] args) { Teacher d = new Teacher(); d.Teach(); Student s = new Student(); s.Learn(); s.Teach(); Console.ReadKey(); } }
  • 8. Multi-level Inheritance Multi-level Inheritance In Multi-level inheritance, a derived class is created from another derived class. Class A (Base) Class B Class C
  • 9. Example – Multi-Level Inheritance //Base Class class Teacher { public void Teach() { Console.WriteLine("Teach"); } } //Base,Derived Class class Student : Teacher { public void Learn() { Console.WriteLine("Learn"); } } //Derived Class class SemFour : Student { public void FourthSem() { Console.WriteLine("Semester Four Students"); } } class Program { static void Main(string[] args) { Teacher d = new Teacher(); d.Teach(); Student s = new Student(); s.Learn(); s.Teach(); SemFour Sem = new SemFour(); Sem.Learn(); Sem.Teach(); Sem.FourthSem(); Console.ReadKey(); } }
  • 11. Multiple Inheritance Multiple Inheritance  In Multiple inheritance, a derived class is created from more than one base class.  This inheritance is not supported by .NET Languages like C#, F# etc. Class A (Base) Class B (Base) Class C
  • 12. Example – Multiple Inheritance //Base Class class Teacher { public void Teach() { Console.WriteLine("Teach"); } } //Base,Derived Class class Student { public void Learn() { Console.WriteLine("Learn"); } } //Derived Class class SemFour : Student , Teacher { public void FourthSem() { Console.WriteLine("Semester Four Students"); } }
  • 13. Multipath Inheritance Multipath Inheritance  In Multipath inheritance, a derived class is created from another derived classes and the same base class of another derived classes.  This inheritance is not supported by .NET Languages like C#, F# etc. Class A Class B Class C Class D
  • 14. Example – Multipath Inheritance
  • 15. Hierarchical Inheritance Class A Class C Class B Class D Class E Class F Class G
  • 17. Hybrid Inheritance Class A Class C Class B Class D Class E Class F
  • 18. Example – Hybrid Inheritance