Method Overloading v/s Method Overriding

The capability of more than one objects to respond to the same message in a different way can be broadly categorized into two types: Method Overloading and Method Overriding.


  • If we have methods with the same name but having different signatures or behaviors in the same scope than the methods are known as overloaded methods and the process is known as method overloading
  • In simple language, we can understand it as a Defining function with the same name, different arguments in same class or base and derive class


  • A Method can be overloaded in the same class as well as in its sub-class
  • Constructors can also be overloaded. In this case, we call the process as constructor overloading



Note: A method having different return types but not having different signatures cannot be said as overloaded methods because it will result in an error stating “signature should be different”.


Example of overloaded methods in System class is print() and println()
Now studying about method overloading in Java raises a question in our minds.
Do you know what is that question?

Question: Can We overload the main method of Java?

Answer: The simple answer is Yes. This is how we will prove it:


Some important rules to remember

  • You can change the argument list of an overloaded method
  • One can change the return type(but at least one argument should be changed ) and access modifier of the overloaded method
  • You can declare the new checked exceptions in the overloaded method
  • You can overload a method in the same or in the subclass


  • Method overriding means having a different implementation of the same method in the inherited or derived class.
  • These two methods would have the same signature, but different implementation.
    One of these would exist in the base or the superclass and other in the derived class.These methods cannot exist in the same class.
  • In simple language, we can understand it as Same Name, Same Arguments, Base and Derive Class




We use @overrride annotation just before the method to denote an overridden method.

Some important rules to remember:

  • You cannot override a final method
  • You cannot override a static method to make it non-static
  •  The overriding method and the overridden method must have the same return type. Java 6.0 allows covariant return types(instead of base class)
  • The number and types of parameters in the overriding and overridden should be same, however, the name can be different
  • If the overriding method has a throws clause in its declaration, then the overridden method can also have throws clause(elimination is possible, derived classes can be used)
  • You cannot override a method that is not inherited
  • You cannot override a method to make it is less accessible, but vice versa is true

Comparing Overloading with Overriding

Arguments Change number/type/sequence cannot change number/type/sequence
Access Modifiers Change Same/Increase Access
Exceptions Change You can reduce or eliminate. No new Exceptions can be added except Unchecked Exceptions
Return Type Change Cannot Change


Leave a Reply

Contact Us
close slider
Contact Us

How can we help you with?