The Art of Polymorphism in Java
Polymorphism
The word
polymorphism when taken separately as “Poly” and “morphs” means
many and forms. Simply polymorphism means many forms. In Java Polymorphism is
the ability of objects to take different forms depending on the specific types
or context in which they are used. This
can simply be called the ability of an object to take multiple forms. Super
level inheritance is used for polymorphism.
Example-:
Types of Polymorphism
Polymorphism
in Java can be categorized into two types.
Compile-time Polymorphism & Runtime
Polymorphism
Compile- time Polymorphism also known as method overloading. Runtime Polymorphism also known as method overriding. You can get a better understanding of method overloading and method overriding click the link below and read my blog post .
👉Method Overloading and Method overriding👈
Difference Between Compile-time Polymorphism & Runtime Polymorphism
why important polymorphism in java💁
·
Easy
to maintain and understand.
·
Being
able to add new functionality to existing classes without breaking the existing
code that uses the base class.
·
That
we can write generic code that can work with different types of objects without
changing the code for each specific type.
Reference-:
https://www.geeksforgeeks.org
Tutorials List - Javatpoint
W3Schools Online Web Tutorials
Article by-: Rasanjali Herath
E-Mail-:rasanjaliherath899@gmail.com
Comments
Post a Comment