Difference between method overloading and overriding in Java

Upasana | August 02, 2019 | 1 min read | 359 views


For more concrete information on method overloading and overriding, you can refer to these two articles.

Difference between method overloading and overriding
Method overloading Method overriding

A class have two or more methods in with the same name and different argument list.

In method overriding superclass and subclass have same method signature.

In overloading return type could vary in both methods.

In overriding return types should be same class or subclass (co-variant return type).

JVM calls the respective method based on the parameters passed to it, at the time of method call. It is also known as static polymorphism.

JVM calls the respective method based on the object used to call the method. It is also known as dynamic polymorphism.

Overloaded methods can declare new or broader checked exceptions.

You shall only throw same or narrowed checked exception (same or sub-class) or none at all.


Top articles in this category:
  1. Method overloading rules in Java
  2. Method Overriding Rules in Java
  3. Java Concurrency Interview Questions
  4. Difference between getOne and findById in Spring Data JPA?
  5. Multi-threading Java Interview Questions for Investment Bank
  6. RBS Java Programming Interview Questions
  7. Sapient Global Market Java Interview Questions and Coding Exercise

Recommended books for interview preparation:

Find more on this topic:
Buy interview books

Java & Microservices interview refresher for experienced developers.