Back to the 2026 paper

Module 3: Methods of Java

20267m

Write a short note on Method Overriding.

Worked SolutionAI Assisted

Method overriding

Overriding occurs when a subclass provides a compatible implementation of an inherited instance method. The method signature must match; the return type must be the same or covariant, access cannot be more restrictive, and checked exceptions cannot be broadened beyond the parent's declaration. Use @Override to catch mistakes.

class Animal { void speak() { System.out.println("..."); } }
class Cat extends Animal {
    @Override void speak() { System.out.println("Meow"); }
}

Overriding supports runtime polymorphism. It differs from overloading, where methods share a name but have different parameter lists.

Similar questions

Free AppAndroid App

Coursify Android App

Generate AI courses, take quick quizzes between classes, and master complex engineering concepts on the go.