TODAY JAVA SCHOOL

In java school, programming, design, computer general knowledge, web application, software, web services, social media, digital marketing, oops, concept of programming language, oops feature, console media, graphics medium, first programming, c, c ++ , Java, PHP, SQL, MySQL, HTML, HTML_5, J_query, JavaScript, Bootstrap, Framework, images with logos, examples, shared and explained.

https://www.amazon.in/b?node=26373545031&linkCode=ll2&tag=1234567801cdb-21&linkId=3b9882431b00409b44141e0344b35a15&language=en_IN&ref_=as_li_ss_tl

Breaking

Tuesday, 7 April 2020

Difference between method overloading and method overriding in java | Difference between method Overloading and Overriding in hindi

Difference between method Overloading and Overriding in java

There are many differences between method overloading and method overriding in java.They are 
 method overriding
Fig: Method Overloading and Method Overriding 

  • Method Overriding
  • Method Overloading

1. Overloading happens at compile-time while Overriding happens at runtime: The binding of overloaded method call to its definition has happens at compile-time however binding of overridden method call to its definition happens at runtime.

2.    Static methods can be overloaded which means a class can have more than one static method of same name. Static methods cannot be overridden, even if you declare a same static method in child class it has nothing to do with the same method of parent class.

3.    The most basic difference is that overloading is being done in the same class while for overriding base and child classes are required. Overriding is all about giving a specific implementation to the inherited method of parent class.

4.    Static binding is being used for overloaded methods and dynamic binding is being used for overridden/overriding methods.

5.    Performance: Overloading gives better performance compared to overriding. The reason is that the binding of overridden methods is being done at runtime.

6.    private and final methods can be overloaded but they cannot be overridden. It means a class can have more than one private/final methods of same name but a child class cannot override the private/final methods of their base class.

7.    Return type of method does not matter in case of method overloading, it can be same or different. However in case of method overriding the overriding method can have more specific return type.
overloading Vs Overriding
Fig: Overriding VS Overloading


No comments:

Post a Comment