Object-oriented programming for Java - 6

Java Polymorphism

 


1. Java Polymorphism

Java Polymorphism use in the same entity (method or operator or object) can perform different operations in different scenarios.

In this example, the render() method perform different in each Class. In here we can point the render() method is Polymorphism.

 

2. Polymorphism using method overriding

Workflow:

Working of Java Polymorphism

 

3. Polymorphism using method overloading

Compare

 

3. Java Operator Overloading

(a). For int

(b). For String

 

4. Polymorphic Variables

Polymorphic Variable: if it refers to different values under different conditions.

Object variables (instance variables) represent the behavior of polymorphic variables in Java.