Advertisement
Google Ad Slot: content-top
Java Polymorphism
Polymorphism is one of the core principles of Object-Oriented Programming (OOP) in Java. It allows one entity (like a method or object) to take multiple forms. The term polymorphism comes from the Greek words "poly" (many) and "morph" (forms), meaning the ability to process objects differently based on their data type or class.
Types of Polymorphism in Java
Compile-Time Polymorphism (also called Static Polymorphism)
- Achieved through method overloading.
- The method to be called is resolved at compile time.
Runtime Polymorphism (also called Dynamic Polymorphism)
- Achieved through method overriding.
- The method to be called is determined at runtime based on the actual object