What happens if a superclass method is overridden by more than one subclass in Java?

When multiple subclasses override the same method from a superclass, each subclass provides its own implementation of that method. At runtime, Java executes the overridden method based on the actual object type, not the reference type. This behavior is known as runtime polymorphism or dynamic method dispatch.

Key Points

Example

Consider an Animal superclass with a makeSound() method. Different subclasses such as Dog and Cat can override this method to provide their own behavior.

class Animal {

    void makeSound() {
        System.out.println("Animal makes a sound");
    }
}

class Dog extends Animal {

    @Override
    void makeSound() {
        System.out.println("Dog barks");
    }
}

class Cat extends Animal {

    @Override
    void makeSound() {
        System.out.println("Cat meows");
    }
}

public class Demo {

    public static void main(String[] args) {

        Animal animal1 = new Dog();
        Animal animal2 = new Cat();

        animal1.makeSound();
        animal2.makeSound();
    }
}

Output

Dog barks

Cat meows

How It Works

Real-World Example

A Payment superclass or interface may define

processPayment()

Different implementations

Each class overrides the same method but performs different actions.

Benefits

Interview Tip

A concise interview answer is

If multiple subclasses override the same superclass method, each subclass maintains its own implementation. When the method is called through a superclass reference, Java executes the version belonging to the actual object type at runtime, which is an example of runtime polymorphism.

Last updated: 16 July 2026

Previous question: How does the @Override annotation influence method overriding?

Next question: What are the 'this' and 'super' keywords in Java?

More Core Java - Level II interview questions

All Core Java - Level II questions