SlideShare a Scribd company logo
Single Inheritance
Dr.J.Jospin Jeya
Single Inheritance in Object-Oriented Programming (OOP)
• Single inheritance refers to a scenario where a class (called the child
class or subclass) inherits properties and behaviors (methods) from
one parent class (called the superclass or base class).
• This is one of the simplest forms of inheritance and a core concept in
many object-oriented programming languages like Java, Python, C++,
etc.
• In single inheritance, the child class can access all non-private
attributes and methods of the parent class, and it can also define its
own additional properties and methods.
Key Points:
• Parent Class: The class that provides the base functionality.
• Child Class: The class that inherits functionality from the parent class.
• The child class can override methods from the parent class if needed.
• It allows code reuse and improves the organization of code.
Example
• # Parent Class (Superclass)
• class Animal:
• def __init__(self, name, species):
• self.name = name
• self.species = species
• def make_sound(self):
• print("Some generic animal sound")
• # Child Class (Subclass)
• class Dog(Animal): # Dog is inheriting from Animal
• def __init__(self, name, species, breed):
• super().__init__(name, species) # Call the parent class constructor
• self.breed = breed
• def make_sound(self): # Overriding the make_sound method
• print("Bark!")
Cont..
• # Create an object of the Dog class
• dog1 = Dog("Buddy", "Dog", "Golden Retriever")
• dog1.make_sound() # Output: Bark!
• print(dog1.name) # Output: Buddy
• print(dog1.species) # Output: Dog
• print(dog1.breed) # Output: Golden Retriever
Cont..
Explanation:
•Parent Class (Animal): Contains the name, species, and a make_sound method.
•Child Class (Dog): Inherits from Animal. It has its own breed attribute and
•overrides the make_sound method to provide a more specific sound ("Bark!").
•The super() function is used to call the constructor (__init__) of the parent class
•so that the child class can initialize the inherited properties.

More Related Content

PDF
Lecture on Python OP concepts of Polymorpysim and Inheritance.pdf
waqaskhan428678
 
PPTX
Inheritance_in_OOP_using Python Programming
abigailjudith8
 
PPTX
601109769-Pythondyttcjycvuv-Inheritance .pptx
srinivasa gowda
 
PDF
Inheritance and polymorphism oops concepts in python
deepalishinkar1
 
PDF
Object oriented Programning Lanuagues in text format.
SravaniSravani53
 
PPTX
Chapter 07 inheritance
Praveen M Jigajinni
 
PPTX
OOP-part-2 object oriented programming.pptx
palmakyonna
 
PPTX
Python programming computer science and engineering
IRAH34
 
Lecture on Python OP concepts of Polymorpysim and Inheritance.pdf
waqaskhan428678
 
Inheritance_in_OOP_using Python Programming
abigailjudith8
 
601109769-Pythondyttcjycvuv-Inheritance .pptx
srinivasa gowda
 
Inheritance and polymorphism oops concepts in python
deepalishinkar1
 
Object oriented Programning Lanuagues in text format.
SravaniSravani53
 
Chapter 07 inheritance
Praveen M Jigajinni
 
OOP-part-2 object oriented programming.pptx
palmakyonna
 
Python programming computer science and engineering
IRAH34
 

Similar to Object Oriented Programming -Single Inheritance.pptx (20)

PDF
All about python Inheritance.python codingdf
adipapai181023
 
PDF
Python programming : Inheritance and polymorphism
Emertxe Information Technologies Pvt Ltd
 
PPTX
Python oop - class 2 (inheritance)
Aleksander Fabijan
 
PPTX
Parent and Child Classes in Object Oriented Programming.pptx
MarioCaday2
 
PPTX
Inheritance
JayanthiNeelampalli
 
PPTX
Inheritance_Polymorphism_Overloading_overriding.pptx
MalligaarjunanN
 
PDF
Java programming -Object-Oriented Thinking- Inheritance
Jyothishmathi Institute of Technology and Science Karimnagar
 
PDF
python note.pdf
Nagendra504676
 
PPT
inheritance in python with full detail.ppt
ssuser7b0a4d
 
PPTX
Object oriented Programming concepts explained(3).pptx
grad25iconinfocus
 
PPTX
OOPS.pptx
NitinSharma134320
 
PDF
Unit_3_2_INHERITANUnit_3_2_INHERITANCE.pdfCE.pdf
RutviBaraiya
 
PDF
Introduction to OOP in python inheritance
Aleksander Fabijan
 
PPTX
METHOD OVERLOADING AND INHERITANCE INTERFACE
mohanrajm63
 
PPTX
Python: Basic Inheritance
Damian T. Gordon
 
PDF
Presentation Slide about Inharitance in Java Object Oriented Programming
Abdullah Al Noman
 
PPTX
PYTHON OBJECT-ORIENTED PROGRAMMING.pptx
hpearl130
 
PPTX
Inheritance in oops
Hirra Sultan
 
PPTX
Python advance
Mukul Kirti Verma
 
PPTX
Object Oriented Programming - Copy.pptxb
benholdhausiku6
 
All about python Inheritance.python codingdf
adipapai181023
 
Python programming : Inheritance and polymorphism
Emertxe Information Technologies Pvt Ltd
 
Python oop - class 2 (inheritance)
Aleksander Fabijan
 
Parent and Child Classes in Object Oriented Programming.pptx
MarioCaday2
 
Inheritance
JayanthiNeelampalli
 
Inheritance_Polymorphism_Overloading_overriding.pptx
MalligaarjunanN
 
Java programming -Object-Oriented Thinking- Inheritance
Jyothishmathi Institute of Technology and Science Karimnagar
 
python note.pdf
Nagendra504676
 
inheritance in python with full detail.ppt
ssuser7b0a4d
 
Object oriented Programming concepts explained(3).pptx
grad25iconinfocus
 
Unit_3_2_INHERITANUnit_3_2_INHERITANCE.pdfCE.pdf
RutviBaraiya
 
Introduction to OOP in python inheritance
Aleksander Fabijan
 
METHOD OVERLOADING AND INHERITANCE INTERFACE
mohanrajm63
 
Python: Basic Inheritance
Damian T. Gordon
 
Presentation Slide about Inharitance in Java Object Oriented Programming
Abdullah Al Noman
 
PYTHON OBJECT-ORIENTED PROGRAMMING.pptx
hpearl130
 
Inheritance in oops
Hirra Sultan
 
Python advance
Mukul Kirti Verma
 
Object Oriented Programming - Copy.pptxb
benholdhausiku6
 
Ad

More from jospinjj (8)

PPTX
Unified Modelling Language Class Diagram.pptx
jospinjj
 
PPTX
Unified Modelling Language Use Case Diagram.pptx
jospinjj
 
PPTX
FEATURES OF OBJECT ORIENTED PROGRAMMING.pptx
jospinjj
 
PPTX
Unified Modelling language Component diagram.pptx
jospinjj
 
PPT
PENETRATION TESTING PRIVILEGE ESCALATION.ppt
jospinjj
 
PPT
PENETRATION TESTING PAYLOAD.ppt
jospinjj
 
PPT
PENETRATION TESTING INFORMATION GATHERING.ppt
jospinjj
 
PPT
PENTRATION TESTING Linux Escalation.ppt
jospinjj
 
Unified Modelling Language Class Diagram.pptx
jospinjj
 
Unified Modelling Language Use Case Diagram.pptx
jospinjj
 
FEATURES OF OBJECT ORIENTED PROGRAMMING.pptx
jospinjj
 
Unified Modelling language Component diagram.pptx
jospinjj
 
PENETRATION TESTING PRIVILEGE ESCALATION.ppt
jospinjj
 
PENETRATION TESTING PAYLOAD.ppt
jospinjj
 
PENETRATION TESTING INFORMATION GATHERING.ppt
jospinjj
 
PENTRATION TESTING Linux Escalation.ppt
jospinjj
 
Ad

Recently uploaded (20)

PPTX
AgentX UiPath Community Webinar series - Delhi
RohitRadhakrishnan8
 
PDF
Unit I Part II.pdf : Security Fundamentals
Dr. Madhuri Jawale
 
PPTX
TE-AI-Unit VI notes using planning model
swatigaikwad6389
 
PDF
Queuing formulas to evaluate throughputs and servers
gptshubham
 
PDF
algorithms-16-00088-v2hghjjnjnhhhnnjhj.pdf
Ajaykumar966781
 
PPT
High Data Link Control Protocol in Data Link Layer
shailajacse
 
PPTX
Fluid Mechanics, Module 3: Basics of Fluid Mechanics
Dr. Rahul Kumar
 
PPTX
Chapter----five---Resource Recovery.pptx
078bce110prashant
 
PPT
Ppt for engineering students application on field effect
lakshmi.ec
 
PDF
Structs to JSON How Go Powers REST APIs.pdf
Emily Achieng
 
PDF
ETO & MEO Certificate of Competency Questions and Answers
Mahmoud Moghtaderi
 
PDF
Chad Ayach - A Versatile Aerospace Professional
Chad Ayach
 
PPTX
Production of bioplastic from fruit peels.pptx
alwingeorgealwingeor
 
PDF
Cryptography and Information :Security Fundamentals
Dr. Madhuri Jawale
 
PDF
FLEX-LNG-Company-Presentation-Nov-2017.pdf
jbloggzs
 
PPTX
EE3303-EM-I 25.7.25 electrical machines.pptx
Nagen87
 
PPTX
Azure-DevOps-Training presentation downloadable
NamanGoyal428595
 
PPTX
Module_II_Data_Science_Project_Management.pptx
anshitanarain
 
PPTX
Strings in CPP - Strings in C++ are sequences of characters used to store and...
sangeethamtech26
 
AgentX UiPath Community Webinar series - Delhi
RohitRadhakrishnan8
 
Unit I Part II.pdf : Security Fundamentals
Dr. Madhuri Jawale
 
TE-AI-Unit VI notes using planning model
swatigaikwad6389
 
Queuing formulas to evaluate throughputs and servers
gptshubham
 
algorithms-16-00088-v2hghjjnjnhhhnnjhj.pdf
Ajaykumar966781
 
High Data Link Control Protocol in Data Link Layer
shailajacse
 
Fluid Mechanics, Module 3: Basics of Fluid Mechanics
Dr. Rahul Kumar
 
Chapter----five---Resource Recovery.pptx
078bce110prashant
 
Ppt for engineering students application on field effect
lakshmi.ec
 
Structs to JSON How Go Powers REST APIs.pdf
Emily Achieng
 
ETO & MEO Certificate of Competency Questions and Answers
Mahmoud Moghtaderi
 
Chad Ayach - A Versatile Aerospace Professional
Chad Ayach
 
Production of bioplastic from fruit peels.pptx
alwingeorgealwingeor
 
Cryptography and Information :Security Fundamentals
Dr. Madhuri Jawale
 
FLEX-LNG-Company-Presentation-Nov-2017.pdf
jbloggzs
 
EE3303-EM-I 25.7.25 electrical machines.pptx
Nagen87
 
Azure-DevOps-Training presentation downloadable
NamanGoyal428595
 
Module_II_Data_Science_Project_Management.pptx
anshitanarain
 
Strings in CPP - Strings in C++ are sequences of characters used to store and...
sangeethamtech26
 

Object Oriented Programming -Single Inheritance.pptx

  • 2. Single Inheritance in Object-Oriented Programming (OOP) • Single inheritance refers to a scenario where a class (called the child class or subclass) inherits properties and behaviors (methods) from one parent class (called the superclass or base class). • This is one of the simplest forms of inheritance and a core concept in many object-oriented programming languages like Java, Python, C++, etc. • In single inheritance, the child class can access all non-private attributes and methods of the parent class, and it can also define its own additional properties and methods.
  • 3. Key Points: • Parent Class: The class that provides the base functionality. • Child Class: The class that inherits functionality from the parent class. • The child class can override methods from the parent class if needed. • It allows code reuse and improves the organization of code.
  • 4. Example • # Parent Class (Superclass) • class Animal: • def __init__(self, name, species): • self.name = name • self.species = species • def make_sound(self): • print("Some generic animal sound") • # Child Class (Subclass) • class Dog(Animal): # Dog is inheriting from Animal • def __init__(self, name, species, breed): • super().__init__(name, species) # Call the parent class constructor • self.breed = breed • def make_sound(self): # Overriding the make_sound method • print("Bark!")
  • 5. Cont.. • # Create an object of the Dog class • dog1 = Dog("Buddy", "Dog", "Golden Retriever") • dog1.make_sound() # Output: Bark! • print(dog1.name) # Output: Buddy • print(dog1.species) # Output: Dog • print(dog1.breed) # Output: Golden Retriever
  • 6. Cont.. Explanation: •Parent Class (Animal): Contains the name, species, and a make_sound method. •Child Class (Dog): Inherits from Animal. It has its own breed attribute and •overrides the make_sound method to provide a more specific sound ("Bark!"). •The super() function is used to call the constructor (__init__) of the parent class •so that the child class can initialize the inherited properties.