Programming

What is method overloading vs method overriding in Java?

Short answer

Overloading means having multiple methods with the same name but different parameters in the same class; overriding means a subclass provides its own implementation of a method it inherited from a parent class, with the same signature.

Both let you reuse a method name, but for different purposes and at different points in a program's structure.

Overloading

Happens within the same class, and is resolved at compile time based on the number or type of arguments passed. For example, a class might have both add(int a, int b) and add(double a, double b) — Java picks the right one based on the argument types you pass.

Overriding

Happens between a parent class and a subclass — the subclass redefines a method it inherited, keeping the same method signature, but giving it new behavior. This is resolved at runtime, based on the actual object type, which is what enables polymorphism in Java.

A simple way to remember it: overloading is about having several versions of a method in one place; overriding is about replacing a method's behavior further down an inheritance chain.

Last reviewed: September 2026