What is method overriding?

202520252025

What is method overriding?

  1. A.

    Replacing a method in the parent class

  2. B.

    Creating a new method in the child class

  3. C.

    Using the method from the parent class in the child class

  4. D.

    Providing a new implementation of a method that is already defined in its superclass

Attempted by 5 students.

Show answer & explanation

Correct answer: D

Method overriding is a core mechanism of runtime polymorphism in object-oriented programming: a subclass defines a method with the exact same name, parameter list, and return type as a method its superclass already declares, and the subclass's version replaces the inherited one whenever that method is invoked on the subclass's own instances.

Here, only one option keeps a method that the superclass already defines and gives it a fresh, subclass-specific body — that is precisely what overriding does, and it is why calling this method on a subclass object executes the subclass's logic instead of the superclass's.

  • Replacing a method in the parent class edits the superclass itself, so the change applies everywhere that class is used — overriding never touches the superclass's code.

  • Creating a new method in the child class adds a capability with no existing counterpart in the superclass — there is nothing being redefined, so nothing is overridden.

  • Using the parent's method as-is inside the child class keeps the inherited behavior completely unchanged — overriding requires the subclass to supply a different implementation, not reuse the original one.

Explore the full course: Hexaware Preparation