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

Budget AppAndroid App

Pocketly on Android

Log daily food, travel, and hostel expenses instantly. Set monthly spending limits and see where your money goes without complex spreadsheets.