What is method overriding in Java?

Method overriding is a feature of Java where a subclass provides its own implementation of a method that is already defined in its parent class. The overridden method must have the same name, parameter list, and compatible return type as the method in the superclass. Method overriding enables runtime polymorphism, allowing Java to execute the appropriate method based on the actual object type.

Key Points

Example

A Vehicle class may define a start() method, but different vehicle types can provide their own implementation of how they start.

class Vehicle {

    void start() {
        System.out.println("Vehicle is starting");
    }
}

class Car extends Vehicle {

    @Override
    void start() {
        System.out.println("Car is starting with a key");
    }
}

public class Demo {

    public static void main(String[] args) {

        Vehicle vehicle = new Car();

        vehicle.start();
    }
}

Output

Car is starting with a key

Rules for Method Overriding

Example of Invalid Overriding

class Parent {

    public void display() {
    }
}

class Child extends Parent {

    private void display() {   // Compilation Error
    }
}

The child method has weaker access privileges, which is not allowed.

Benefits of Method Overriding

Interview Tip

A concise interview answer is

Method overriding occurs when a subclass provides its own implementation of a method already defined in the parent class. The method must have the same name, parameters, and compatible return type. It is the foundation of runtime polymorphism in Java.

Last updated: 16 July 2026

Previous question: What are the rules for method overloading in Java?

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

More Core Java - Level II interview questions

All Core Java - Level II questions