Explore Topics
Polymorphism means "one name with many forms." Compile-time polymorphism (static binding) occurs when the compiler determines which method to call based on the method signature at compile time. Method overloading lets a class define multiple methods with the same name but different parameter lists β varying in number, type, or order of parameters. The compiler matches the call to the correct overload during compilation, so there is zero runtime overhead.
- Polymorphism = "poly" (many) + "morph" (forms)
- Method overloading = same name, different parameter signatures
- Parameters can vary in number, type, or order
- Resolved at COMPILE TIME (static binding / early binding)
- No runtime overhead β the JVM knows exactly which method to call
- Return type alone does NOT make a valid overload
- β¦Clean API β one intuitive method name for related operations
- β¦Type safety enforced at compile time β no guessing at runtime
- β¦Zero performance overhead compared to dynamic dispatch
- β¦Enables fluent APIs and builder patterns
- β³Too many overloads can confuse callers (which one will be called?)
- β³Auto-widening (intβdouble) can cause unexpected overload resolution
- β³Cannot overload by return type alone β compiler can't disambiguate
- β³Default parameter values (like in Kotlin/Python) often cleaner than many overloads
Code Examples
Each topic has a self-contained Java example. Switch between topics above, then click the Code tab to explore line-by-line.
Quiz
Animal a = new Dog(); a.speak(); a.breathe();
Parent ref = new Child(); ref.greet(); // static method ref.introduce(); // instance method
Vehicle v = new ElectricCar(); v.start();