1.

What Is The Difference Between Method Overloading And Overriding In Java?

Answer»

METHOD overloading happens during compile TIME within a class whereas Method Overriding happens between two classes that have IS-A i.e. inheritance relationship. For method overriding we require parent and child classes whereas for method overloading a single class is enough.

  • Static binding is used for method overloading as the call to the overloaded method is made during the compile time whereas dynamic binding is used for method overriding as the call to the OVERRIDDEN method is made at run time.
  • Method overloading requires different argument LIST to the method whereas in method overriding the argument list has to be same.
  • Method overloading GIVES better performance over method overriding since the binding of the overloaded methods is done at compile time and not run time.

Method overloading happens during compile time within a class whereas Method Overriding happens between two classes that have IS-A i.e. inheritance relationship. For method overriding we require parent and child classes whereas for method overloading a single class is enough.



Discussion

No Comment Found