Careeroza
What is Polymorphism
Many Forms
Polymorphism means "many forms". The same call does different things depending on the types involved. Java has two kinds:
| Compile-time (static) | Runtime (dynamic) | |
|---|---|---|
| Achieved by | method overloading | method overriding |
| Decided | by the compiler, from argument types | by the JVM, from the actual object |
| Also called | static binding, early binding | dynamic dispatch, late binding |
| Example | print(int) vs print(String) | shape.area() on Circle or Square |