What are the rules for method overloading versus overriding, and can you overload a method by changing only the return type?

Last updated 5 July 2026

  • Overloading: same name, different parameter list (count, types, or order) in the same scope. It is resolved at compile time by argument types.

  • Overriding: same signature as an inherited method with identical or covariant return type, no more restrictive access, and no broader checked exceptions. It is resolved at runtime.

  • You cannot overload by return type alone: a call like foo() gives the compiler no way to choose, so it's a compile error.

  • https://www.baeldung.com/java-method-overload-override
  • https://www.geeksforgeeks.org/java/invalid-method-overloading-in-java/
All Object-Oriented Programming interview questions