Department of Computational Science
BSIT | BSCS | BSMath
IPT1
Integrative Coding
Polymorphism
Jomarie S. Isorena
Polymorphism
● Polymorphism means that a variable of a supertype can refer to a
subtype object.
○ A type defined by a subclass is called a subtype, and a type
defined by its superclass is called a supertype.
Polymorphism
● According to Chemistry:
○ The term polymorphism can be defined as the ability of any
element or compound to exit in multiple crystalline forms is
called Polymorphism.
● According to Java:
○ Polymorphism is defined as the ability of any object in a class to
perform a particular task in multiple methods is known as
Polymorphism in Java
Polymorphism
Polymorphism
Polymorphism
Polymorphism - Characteristics
● The functionality of a method behaves different situation
● The behavior of a method is depended on the data
● Polymorphism is mainly used to implement inheritance
● It allows same name for a member or method in a class with different
types
Polymorphism - TYPES
● Compile-Time Polymorphism
● Run-Time Polymorphism
Polymorphism - TYPES
● Compile-Time Polymorphism
○ Gets executed during
compilation stage. Here, the
overloading method gets
resolved in compilation
stage
○ Also known as static
polymorphism
Polymorphism - TYPES
● Run-Time Polymorphism
○ Gets handled during the
program execution stage. Here,
the overriding method gets
resolved in execution stage.
○ Also known as Dynamic Binding
or Dynamic Method Dispatch
Polymorphism
Compile-time Polymorphism Run-time Polymorphism
Method call is handled by the compiler itself Method call cannot handled by the compiler
in execution time
Compile-time polymorphism is less flexible as Run-time polymorphism exhibit flexible as
it needs handle all method calls in the method calls gets handled at run-time
compile-time
Integrating the right method call with the right Integrating the right method call with the right
method is doe in compile-time method is doe in run-time
Occurs during Method Overloading Occurs during Method Overriding
Department of Computational Science
BSIT | BSCS | BSMath
Thank you!