You are on page 1of 14

Presentation

of
Group 3:
Polymorphism
What is Polymorphism?
It is an oop technique that utilizes
inheritance to create 1 class and make
several classes inherit from that class so
that it can take many forms.
According to Dictionary
"Poly" means "MANY" and
Morph means "Take Different
Forms"
USING Polymorphism
class Animal {
void makeSound(){
//Sound
}
}
class Dog extends Animal void
makeSound(){
//Arf
}
class Cat extends Animal void
} makeSound(){
//Meow
}

}
Java Polymorphism
Polymorphism is one of the basic principles of
Object-Oriented Programming. There are two
types of polymorphism:

• Static Polymorphism
• Dynamic Polymorphism
Polymorphism is the capability of
an action or method to do different
things based on the object.
Compile Time in Java Polymorphism

Compile time polymorphism in Java is also known as early


binding or static polymorphism. The binding is performed
during compilation time and hence the name compile-time
polymorphism. Binding refers to connecting the function call to
the function body.
Runtime in Java Polymorphism

Runtime polymorphism, also known as the Dynamic Method


Dispatch, is a process that resolves a call to an overridden
method at runtime. The process involves the use of the reference
variable of a superclass to call for an overridden method.
Method Overloading

Method overloading is defining more than one method with


the same name but with different method signatures. The
name of the method is the same but the number and type of
method parameters and method return types might be
different. When an overloaded method is encountered, Java
executes the version of the method whose parameters match
the arguments used in the method call.
Method overriding

Method overriding allows programmers to provide different


implementations for the methods in parent class and subclasses.
The method name and the method signature would be the same
but with different implementations. The actual method called
depends on the type of object at runtime.
THANK YOU
FOR
LISTENING

You might also like