Category: React • Beginner
Published on 22 Feb 2026
Explanation
#white-Compile-time polymorphism is achieved #white-using method overloading.
Code Example
int add(int a, int b) { return a + b; }
double add(double a, double b) { return a + b; }
Explanation
#white-Runtime polymorphism is achieved using #white-method overriding.
Code Example
class A { void show() { System.out.println("A"); } }
class B extends A { void show() { System.out.println("B"); } }
Explanation
#white-In compile-time polymorphism, method #white-resolution happens at compile time.
Code Example
Calculator c = new Calculator(); c.add(10, 20);
Explanation
#white-In runtime polymorphism, method call #white-depends on object type at runtime.
Code Example
A obj = new B(); obj.show();
Explanation
#white-Overloading requires different method signatures.
Code Example
void print(int a) {}
void print(String a) {}