OOP Interview Question

What is the difference between overloading and overriding?

Updated 2026-07-10 · Beginner friendly
Quick answer

Method overloading means having several methods with the same name but different parameters in the same class, and it is decided at compile time. Method overriding means a child class provides its own version of a method it inherited from a parent, and it is decided at run time. Overloading is about many forms of one method name, overriding is about replacing inherited behaviour.

Overloading: same name, different inputs

Overloading lets you use one friendly method name for related actions that take different inputs. The compiler picks the right one based on the arguments you pass. This happens in a single class.

class Calculator {
    int add(int a, int b) { return a + b; }
    double add(double a, double b) { return a + b; }
    int add(int a, int b, int c) { return a + b + c; }
}

Overriding: child replaces parent behaviour

Overriding happens across two classes linked by inheritance. The child keeps the same method name and parameters as the parent but gives its own body. At run time the program uses the child version.

class Animal {
    void sound() { System.out.println("some sound"); }
}
class Cat extends Animal {
    @Override
    void sound() { System.out.println("meow"); }
}

Animal a = new Cat();
a.sound();   // prints meow

Quick comparison

In the interview

A favourite follow up is whether you can override a static method. The answer is no, that is called method hiding, not overriding, because static methods belong to the class and are resolved at compile time. Mentioning this shows depth.

Want the full OOP guide?

Read every OOP concept with notes, diagrams, and code in one place. Track your progress as you go.

Open the OOP guide All OOP questions