Java- Difference Between Method Overloading & Method Overriding / Chapter - 8 / OOP's Concept

Method Overloading,Method Overriding Difference between Method Overloading and Method Overriding 



  1. Method Names: - In Overloading method name should be same, And Even In Overriding method name should be same.

  2. Argument Type: - In Overloading, argument type must be different (at least the order of arguments), But in the Overriding argument type must be same.

  3. Method Signature: - In Overloading, method signature must be different, But in the Overriding method signature must be same.

  4. Return Type: - In Overloading, there is no restriction on the return type, But in Overriding return type must be same until 1.4 v, But from 1.5v onwards co-variant return type is allowed.

  5. private, static, final modifiers:In Overloading, these modifiers consist method can be overloaded, But in Overriding these modifiers consists method can be overridden.

  6. Access modifier: - In Overloading, there is no restriction with the access modifier, But in Overriding, we can't reduce the scope of the modifier but we can increase the scope.

  7. throws clause: - In Overloading, there is no restriction with the throws clause, But in Overriding if child class method throws any checked exception compulsory parent class method should throw the same checked exception or its parent but no restriction with the unchecked exceptions.

  8. method resolution: -  In Overloading, method resolution is always taken care by the compiler based on the reference type, But in the Overriding method resolution is always taken care by JVM based on runtime object.

  9. It is also known as -  Overloading is also known as compile-time polymorphism or static polymorphism But Overriding is also known as run-time polymorphism or dynamic polymorphism.

2 comments:

Be the first to comment!

Don't just read and walk away, Your Feedback Is Always Appreciated. I will try to reply to your queries as soon as time allows.

Note:
1. If your question is unrelated to this article, please use our Facebook Page.
2. Please always make use of your name in the comment box instead of anonymous so that i can respond to you through your name and don't make use of Names such as "Admin" or "ADMIN" if you want your Comment to be published.

Regards,
JavaByChetan
Back To Home

Flipkart End Of Season Sale






© Copyright 2017 Javabychetan.blogspot.com