0% found this document useful (0 votes)
4 views4 pages

Day 52 Polymorphism

The document provides an overview of Object-Oriented Programming (OOP) concepts using Python, including classes, objects, inheritance, and polymorphism. It explains method overriding, method hiding, and the lack of method overloading in Python, along with examples. Additionally, it touches on abstract methods, access specifiers, and multithreading.

Uploaded by

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

Day 52 Polymorphism

The document provides an overview of Object-Oriented Programming (OOP) concepts using Python, including classes, objects, inheritance, and polymorphism. It explains method overriding, method hiding, and the lack of method overloading in Python, along with examples. Additionally, it touches on abstract methods, access specifiers, and multithreading.

Uploaded by

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

OOPs Using Python

~~~~~~~~~~~~~~~~~~~

class and object


data member
method
constructor and repr
destructor and gc
inheritance
what is inh
syntax
attrs
diff medium
real time situation
why inh
types of inh
ambiguity
mro

~~~~~~~~~~~~~~~~~~~~~
POLYMORPHISM
~~~~~~~~~~~~~~~~~~~~~
poly + moraphism
many + form

in the market of oops


polymorphism is basically 3 types,
c++ java python
1. method overriding yes yes yes
2. method hiding yes no yes
3. method overloading yes yes no

METHOD OVERRIDING

MULTIPLE METHOD
HAVING SAME NAME
AND SAME PARAM
IN DIFF CLASS
WITH INHERITANCE

METHOD HIDING

MULTIPLE METHOD
HAVING SAME NAME
AND DIFF PARAM
IN DIFF CLASS
WITH INHERITANCE

METHOD OVERLOADING :: not supported by python

MULTIPLE METHOD
HAVING SAME NAME
AND DIFF PARAM
IN ONE CLASS

===========================================================================
class parent :

def home ( self ) :


print ( 'welcome to parent home.')

def food ( self ) :


print ( 'welcome to parent food')

class child ( parent ) :

def home ( self ) : # method overriding


print ( 'welcome to child home.')

def food ( self , payment ) : # method hiding


print ( 'welcome to child paid food.')

obj = child ()
obj . home ()
obj . food ( )

==============================================================================

how to access hidden method

parentClassName . hiddenMethodName ( childObjName )

how to access overrided method

parentClassName . overridedMethodName ( childObjName )

class parent :

def home ( self ) :


print ( 'welcome to parent home.')

def food ( self ) :


print ( 'welcome to parent food')

class child ( parent ) :

def home ( self ) : # method overriding


print ( 'welcome to child home.')

def food ( self , payment ) : # method hiding


print ( 'welcome to child paid food.')

obj = child ()
obj . home ()
obj . food ( 100 )
# obj . food ( ) TypeError
parent . food ( obj )
parent . home ( obj )

=========================================================================

IN PYTHON, POLYMORPHISM IS ONLY POSIBLE WITH INHERITANCE.

====================================================================
class and object
data member
method
constructor and repr
destructor and gc
inheritance
polymorphism

ABSTRACT METHOD AND ABSTRACT CLASS 1


ACCESS SPECIFIERS 1

MULTITHREADINGS 2

=====================================================================

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy