Polymorphism
1. Agenda What is and Why Polymorphism?
● Examples of Polymorphism in Java
programs ● 3 forms of Polymorphism ● 2
2. What is & Why Polymorphism? 3
3. What is Polymorphism? Generally,
polymorphism refers to the ability to ●
appear in many forms Polymorphism in a
Java program ● The ability of a reference
variable to change – behavior according to
what object instance it is holding. This allows
multiple objects of different subclasses – to be
treated as objects of a single super class,
while automatically selecting the proper
methods to apply to a particular object based
on the subclass it belongs to 4
4. Polymorphism Example For example,
given a base class shape, ● polymorphism
enables the programmer to define different
area methods for any number of derived
classes, such as circles, rectangles and
triangles. No matter what shape an object is,
applying the ● area method to it will return
the correct results.