{"id":1042,"date":"2023-05-21T05:26:53","date_gmt":"2023-05-21T05:26:53","guid":{"rendered":"https:\/\/itnotes.apjsoftwares.com\/?p=1042"},"modified":"2023-05-21T05:33:00","modified_gmt":"2023-05-21T05:33:00","slug":"what-is-meant-by-method-overriding","status":"publish","type":"post","link":"https:\/\/itnotes.apjsoftwares.in\/index.php\/2023\/05\/21\/what-is-meant-by-method-overriding\/","title":{"rendered":"What is meant by Method Overriding?"},"content":{"rendered":"\n<p><strong>Method overriding happens if the sub-class method satisfies the below conditions with the Super-class method:<\/strong><\/p>\n\n\n\n<ul>\n<li>Method name should be the same<\/li>\n\n\n\n<li>The argument should be the same<\/li>\n\n\n\n<li>Return type should also be the same<\/li>\n<\/ul>\n\n\n\n<p>The key benefit of overriding is that the Sub-class can provide some specific information about that sub-class type than the super-class.<\/p>\n\n\n\n<p>Example:<\/p>\n\n\n\n<p>public class Manipulation{ \/\/Super class<br>public void add(){<br>\u2026\u2026\u2026\u2026\u2026\u2026<br>}<br>}<\/p>\n\n\n\n<p>Public class Addition extends Manipulation(){<br>Public void add(){<br>\u2026\u2026\u2026..<br>}<br>Public static void main(String args[]){<br>Manipulation addition = new Addition(); \/\/Polimorphism is applied<br>addition.add(); \/\/ It calls the Sub class add() method<br>}<br>}<br>addition.add() method calls the add() method in the Sub-class and not the parent class. So it overrides the Super-class method and is known as Method Overriding.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Method overriding happens if the sub-class method satisfies the below conditions with the Super-class method:&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[18],"tags":[],"_links":{"self":[{"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/posts\/1042"}],"collection":[{"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/comments?post=1042"}],"version-history":[{"count":1,"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/posts\/1042\/revisions"}],"predecessor-version":[{"id":1043,"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/posts\/1042\/revisions\/1043"}],"wp:attachment":[{"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/media?parent=1042"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/categories?post=1042"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/tags?post=1042"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}