OOP Interview Question

What is polymorphism in OOP?

Updated 2026-07-10 · Beginner friendly
Quick answer

Polymorphism means one name taking many forms, so the same method call can behave differently depending on the object. It comes in two types. Compile time polymorphism is achieved through method overloading, and run time polymorphism is achieved through method overriding. It lets you write flexible code that works with many related types through one interface.

The simple meaning

The word polymorphism comes from many forms. In code it means you can use a single method name and the program decides which actual behaviour to run based on the object involved. This keeps your code clean and open to new types.

Compile time polymorphism

This is achieved with method overloading. Several methods share a name but take different parameters, and the compiler picks the right one before the program runs.

int area(int side) { return side * side; }
int area(int l, int b) { return l * b; }

Run time polymorphism

This is achieved with method overriding. A parent reference can point to a child object, and the child version of the method runs at run time. This is the powerful form used in real designs.

class Shape {
    void draw() { System.out.println("drawing shape"); }
}
class Circle extends Shape {
    @Override
    void draw() { System.out.println("drawing circle"); }
}

Shape s = new Circle();
s.draw();   // prints drawing circle

Why it matters

Polymorphism lets you write code against a general type like Shape and add new shapes later without touching the old code. This is the foundation of flexible and extendable software.

In the interview

A clean interview answer names both types and gives one example each. Say overloading is compile time and overriding is run time, then show a Shape and Circle example for the run time case, since that is the one interviewers care about most.

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