Powered by Blogger.

Difference Between Overloading and Overriding in Java



Difference Between Overloading and Overriding in Java

Hello once again we discuss about difference between overloading and overriding in java. This is frequently asked in any interview question.

Overloading occurs when two or more methods in one class have the same method name but different parameters.
Overriding means having two methods with the same method name and parameters (i.e., method signature).

  • Overloading happens at compile-time while Overriding happens at runtime
  • overloading is being done in the same class while for overriding base and child classes are required.
  • Method overloading is performed within class. Method overriding occurs in two classes that have IS-A (inheritance) relationship.
  • In case of method overloading, parameter must be different. In case of method overriding, parameter must be same.
  • Overloaded method are fast as compare to Overridden method in Java
  • You can not override static, final and private method in Java but you can overload static, final or private method in Java.
  • Overloaded method in Java is bonded by static binding and overridden methods are subject to dynamic binding.




facebook
google-plus
twitter
pinterest

No comments :

Post a Comment

HTML Tutorial

images

About Sitesbay

This blog is related to Java Tutorial, C++ Tutorial, C Tutorial, Online Earning tips and more in very simple and easy way. Here i will try to give complete idea related to all new technology.

Java Tutorial

Java is Object oriented programming language, It is more secure and high performance language.

C++ Tutorial

C++ is also Object oriented programming language, It is more simple and easy to learn.

 
https://sitesbay.blogspot.com/?utm_medium=d2898efa59afcc0bc411921036e22b767ca37b09