Java Learner logo

Module 7: Advanced Object-Oriented Concepts

Lesson focus

Method Overriding Rules & Contracts

Revisit overriding with an emphasis on covariant return types, visibility constraints, and exception compatibility.

Overriding methods may widen visibility (protected → public) but never restrict it.

Java allows covariant returns—an override can return a subtype of the original return type, improving fluency.

Checked exceptions declared in overrides must be the same or a subtype of the base declaration; unchecked exceptions remain unrestricted.

Lesson quiz

Can an overriding method throw a broader checked exception?

Next lesson →