0% found this document useful (0 votes)
3 views1 page

Oops 3 01

Polymorphism refers to the ability to present the same interface for different underlying forms, illustrated through examples like varying behaviors in different contexts and the dual functionality of operators. Key topics related to polymorphism include Duck Typing in Python, overloading (operator, method, and constructor), and overriding (method and constructor). Duck Typing allows for dynamic type determination at runtime, emphasizing behavior over explicit type declaration.

Uploaded by

vishnu050621
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)
3 views1 page

Oops 3 01

Polymorphism refers to the ability to present the same interface for different underlying forms, illustrated through examples like varying behaviors in different contexts and the dual functionality of operators. Key topics related to polymorphism include Duck Typing in Python, overloading (operator, method, and constructor), and overriding (method and constructor). Duck Typing allows for dynamic type determination at runtime, emphasizing behavior over explicit type declaration.

Uploaded by

vishnu050621
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/ 1

Polymorphism

Poly means many. Morphs means forms.


Polymorphism means 'Many Forms'.

Eg1: Yourself is best example of polymorphism.In front of Your parents You will have one type of
behaviour and with friends another type of behaviour.Same person but different behaviours at
different places,which is nothing but polymorphism.

Eg2: + operator acts as concatenation and arithmetic addition

Eg3: * operator acts as multiplication and repetition operator

Eg4: The Same method with different implementations in Parent class and child
classes.(overriding)

Related to polymorphism the following 4 topics are important

1. Duck Typing Philosophy of Python

2. Overloading
1. Operator Overloading
2. Method Overloading
3. Constructor Overloading

3. Overriding
1. Method overriding
2. constructor overriding

1. Duck Typing Philosophy of Python:


In Python we cannot specify the type explicitly. Based on provided value at runtime the type will
be considered automatically. Hence Python is considered as Dynamically Typed Programming
Language.

def f1(obj):
obj.talk()

What is the type of obj? We cannot decide at the beginning. At runtime we can pass any type.Then
how we can decide the type?
At runtime if 'it walks like a duck and talks like a duck,it must be duck'. Python follows this
principle. This is called Duck Typing Philosophy of Python.

nd
DURGASOFT, # 202, 2 Floor, HUDA Maitrivanam, Ameerpet, Hyderabad - 500038,
1  040 – 64 51 27 86, 80 96 96 96 96, 92 46 21 21 43 | www.durgasoft.com

You might also like