{"id":1493,"date":"2023-05-21T08:28:39","date_gmt":"2023-05-21T08:28:39","guid":{"rendered":"https:\/\/itnotes.apjsoftwares.com\/?p=1493"},"modified":"2023-05-21T08:28:40","modified_gmt":"2023-05-21T08:28:40","slug":"explain-inheritance-with-example","status":"publish","type":"post","link":"https:\/\/itnotes.apjsoftwares.in\/index.php\/2023\/05\/21\/explain-inheritance-with-example\/","title":{"rendered":"Explain Inheritance with example"},"content":{"rendered":"\n<p>Inheritance is a feature used in\u00a0object-oriented programming; it refers to defining a new class with less or no modification to an existing class. The new class is called the derived class, and from one which it inherits is called the base. Python supports inheritance; it also supports multiple inheritances. A class can inherit attributes and behavior methods from another class called subclass or heir class.<\/p>\n\n\n\n<p><strong>Example of inheritance:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># Example file for working with classes\nclass myClass():\n  def method1(self):\n      print(\"Guru99\")\n         \n class childClass(myClass):\n  #def method1(self):\n        #myClass.method1(self);\n        #print (\"childClass Method1\")\n         \n  def method2(self):\n        print(\"childClass method2\")     \n          \ndef main():           \n  # exercise the class methods\n  c2 = childClass()\n  c2.method1()\n  #c2.method2()\n\nif __name__== \"__main__\":\n  main()<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Inheritance is a feature used in\u00a0object-oriented programming; it refers to defining a new class with&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[20],"tags":[],"_links":{"self":[{"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/posts\/1493"}],"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=1493"}],"version-history":[{"count":1,"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/posts\/1493\/revisions"}],"predecessor-version":[{"id":1494,"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/posts\/1493\/revisions\/1494"}],"wp:attachment":[{"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/media?parent=1493"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/categories?post=1493"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/tags?post=1493"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}