{"id":1258,"date":"2016-04-07T07:36:10","date_gmt":"2016-04-07T07:36:10","guid":{"rendered":"http:\/\/abhiandroid.com\/java\/?p=1258"},"modified":"2016-04-07T07:36:10","modified_gmt":"2016-04-07T07:36:10","slug":"method-overloading-vs-method-overriding-in-java","status":"publish","type":"post","link":"https:\/\/abhiandroid.com\/java\/method-overloading-vs-method-overriding-in-java.html","title":{"rendered":"Method Overloading vs Method Overriding In JAVA"},"content":{"rendered":"<p>In this section we are going to discuss the difference between method overloading and method overriding. Firstly understand the definition of both terms in brief:<\/p>\n<p>Method overloading refers to a concept in which we have more than one method with a same name but differ in the number or types of parameters within a same class.<\/p>\n<p>Method overriding refers to a concept in which we redefine the method in child class with same name, same return type and same parameter list as its parent class method.<\/p>\n<table width=\"652\" Border=\"1\">\n<tbody>\n<tr>\n<td width=\"326\">\n<p style=\"text-align: center;\"><strong>Method Overloading<\/strong><\/p>\n<\/td>\n<td width=\"326\">\n<p style=\"text-align: center;\"><strong>Method Overriding<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"326\">Method overloading is used\u00a0to increase the readability\u00a0of the program.<\/td>\n<td width=\"326\">Method overriding is used\u00a0to give the specific implementation\u00a0of the method that is already provided by its parent class.<\/td>\n<\/tr>\n<tr>\n<td width=\"326\">Method overloading is done\u00a0within class.<\/td>\n<td width=\"326\">Method overriding occurs\u00a0in two classes\u00a0that have IS-A relationship.<\/td>\n<\/tr>\n<tr>\n<td width=\"326\">In case of method overloading,\u00a0parameter must be different.<\/td>\n<td width=\"326\">In case of method overriding,\u00a0parameter must be same.<\/td>\n<\/tr>\n<tr>\n<td width=\"326\">Method overloading is the example of\u00a0compile time polymorphism.<\/td>\n<td width=\"326\">Method overriding is the example of\u00a0run time polymorphism.<\/td>\n<\/tr>\n<tr>\n<td width=\"326\">Method overloading cannot be performed by changing return type of the method only.\u00a0Return type can be same or different, but there must change in the parameter.<\/td>\n<td width=\"326\">Return type must be same or covariant\u00a0in method overriding.<\/td>\n<\/tr>\n<tr>\n<td width=\"326\">In method overloading, you can overload method in same class.<\/td>\n<td width=\"326\">In method overriding, you can only override method in child class.<\/td>\n<\/tr>\n<tr>\n<td width=\"326\">In method overloading, you\u00a0<a href=\"http:\/\/java67.blogspot.sg\/2012\/08\/can-we-overload-static-method-in-java.html\">can overload static method in Java<\/a><\/td>\n<td width=\"326\">In method overriding, you\u00a0<a href=\"http:\/\/java67.blogspot.sg\/2012\/08\/can-we-override-static-method-in-java.html\">cannot override static method in Java<\/a>.<\/td>\n<\/tr>\n<tr>\n<td width=\"326\">In method overloading, private and final method can be overloaded in Java.<\/td>\n<td width=\"326\">In method overriding, private and final method cannot be overridden in Java.<\/td>\n<\/tr>\n<tr>\n<td width=\"326\">It may or may not need<strong>\u00a0<\/strong>inheritance\u00a0in Method Overloading.<\/td>\n<td width=\"326\">It always requires inheritance in Method Overriding.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n","protected":false},"excerpt":{"rendered":"<p>In this section we are going to discuss the difference between method overloading and method overriding. Firstly understand the definition of both terms in brief: Method overloading refers to a concept in which we have more than one method with a same name but differ in the number or types of parameters within a same &hellip; <a href=\"https:\/\/abhiandroid.com\/java\/method-overloading-vs-method-overriding-in-java.html\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Method Overloading vs Method Overriding In JAVA<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1258","post","type-post","status-publish","format-standard","hentry","category-archieve"],"psp_head":"<title>Method Overloading vs Method Overriding In JAVA \u2013 Abhi Android<\/title>\r\n<meta name=\"description\" content=\"In this section we are going to discuss the difference between method overloading and method overriding. Firstly understand the definition of both terms in brief:\" \/>\r\n<meta name=\"robots\" content=\"index,follow\" \/>\r\n<link rel=\"canonical\" href=\"https:\/\/abhiandroid.com\/java\/method-overloading-vs-method-overriding-in-java.html\" \/>\r\n","_links":{"self":[{"href":"https:\/\/abhiandroid.com\/java\/wp-json\/wp\/v2\/posts\/1258","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/abhiandroid.com\/java\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/abhiandroid.com\/java\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/abhiandroid.com\/java\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/abhiandroid.com\/java\/wp-json\/wp\/v2\/comments?post=1258"}],"version-history":[{"count":1,"href":"https:\/\/abhiandroid.com\/java\/wp-json\/wp\/v2\/posts\/1258\/revisions"}],"predecessor-version":[{"id":1454,"href":"https:\/\/abhiandroid.com\/java\/wp-json\/wp\/v2\/posts\/1258\/revisions\/1454"}],"wp:attachment":[{"href":"https:\/\/abhiandroid.com\/java\/wp-json\/wp\/v2\/media?parent=1258"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/abhiandroid.com\/java\/wp-json\/wp\/v2\/categories?post=1258"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/abhiandroid.com\/java\/wp-json\/wp\/v2\/tags?post=1258"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}