{"id":25539696,"date":"2022-08-26T01:35:16","date_gmt":"2022-08-25T20:05:16","guid":{"rendered":"https:\/\/entri.app\/blog\/?p=25539696"},"modified":"2022-11-19T14:33:24","modified_gmt":"2022-11-19T09:03:24","slug":"introduction-to-inheritance-in-java","status":"publish","type":"post","link":"https:\/\/entri.app\/blog\/introduction-to-inheritance-in-java\/","title":{"rendered":"Introduction To Inheritance In Java"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_79_2 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-69e9daeb6393c\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-69e9daeb6393c\"  aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/entri.app\/blog\/introduction-to-inheritance-in-java\/#Terms_used_in_Inheritance\" >Terms used in Inheritance<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/entri.app\/blog\/introduction-to-inheritance-in-java\/#Types_of_inheritance_in_java\" >Types of inheritance in java<\/a><\/li><\/ul><\/nav><\/div>\n<p>Inheritance in Java\u00a0is a mechanism in which one object acquires all the properties and behaviors of a parent object. It is an important part of\u00a0OOPs\u00a0(Object Oriented programming system).<\/p>\n<p>The idea behind inheritance in Java is that you can create new\u00a0classes\u00a0that are built upon existing classes. When you inherit from an existing class, you can reuse methods and fields of the parent class. Moreover, you can add new methods and fields in your current class also.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Terms_used_in_Inheritance\"><\/span><strong>Terms used in Inheritance<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<ul>\n<li><strong>Class:<\/strong>\u00a0A class is a group of objects which have common properties. It is a template or blueprint from which objects are created.<\/li>\n<li><strong>Sub Class\/Child Class:<\/strong>\u00a0Subclass is a class which inherits the other class. It is also called a derived class, extended class, or child class.<\/li>\n<li><strong>Super Class\/Parent Class:<\/strong>\u00a0Superclass is the class from where a subclass inherits the features. It is also called a base class or a parent class.<\/li>\n<li><strong>Reusability:<\/strong>\u00a0As the name specifies, reusability is a mechanism which facilitates you to reuse the fields and methods of the existing class when you create a new class. You can use the same fields and methods already defined in the previous class.<\/li>\n<\/ul>\n<p style=\"text-align: center;\"><strong><a href=\"https:\/\/bit.ly\/3ELmCiA\" target=\"_blank\" rel=\"noopener\">Learn to code from industry experts! Enroll here!<\/a><\/strong><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Types_of_inheritance_in_java\"><\/span><strong>Types of inheritance in java<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>On the basis of class, there can be three types of inheritance in java: single, multilevel and hierarchical.<\/p>\n<h3><strong>Single Inheritance\u00a0<\/strong><\/h3>\n<p>When a class inherits another class, it is known as a\u00a0single inheritance. In the example given below, Dog class inherits the Animal class, so there is the single inheritance.<\/p>\n<p><strong>File: TestInheritance.java<\/strong><\/p>\n<p><strong>class<\/strong>Animal{<\/p>\n<p><strong>void<\/strong>\u00a0eat(){System.out.println(\u201ceating\u2026\u201d);}<\/p>\n<p>}<\/p>\n<p><strong>class<\/strong>\u00a0Dog\u00a0<strong>extends<\/strong>\u00a0Animal{<\/p>\n<p><strong>void<\/strong>bark(){System.out.println(\u201cbarking\u2026\u201d);}<\/p>\n<p>}<\/p>\n<p><strong>class<\/strong>TestInheritance{<\/p>\n<p><strong>public<\/strong>\u00a0<strong>static<\/strong>\u00a0<strong>void<\/strong>\u00a0main(String\u00a0args[]){<\/p>\n<p>Dog\u00a0d=<strong>new<\/strong>Dog();<\/p>\n<p>d.bark();<\/p>\n<p>eat();<\/p>\n<p>}}<\/p>\n<p><strong>Output:<\/strong><\/p>\n<p>barking\u2026eating\u2026<\/p>\n<h3><strong>Multilevel Inheritance\u00a0<\/strong><\/h3>\n<p>When there is a chain of inheritance, it is known as\u00a0multilevel inheritance. As you can see in the example given below, BabyDog class inherits the Dog class which again inherits the Animal class, so there is a multilevel inheritance.<\/p>\n<p><strong>File: TestInheritance2.java<\/strong><\/p>\n<p><strong>class<\/strong>Animal{<\/p>\n<p><strong>void<\/strong>\u00a0eat(){System.out.println(\u201ceating\u2026\u201d);}<\/p>\n<p>}<\/p>\n<p><strong>class<\/strong>\u00a0Dog\u00a0<strong>extends<\/strong>\u00a0Animal{<\/p>\n<p><strong>void<\/strong>bark(){System.out.println(\u201cbarking\u2026\u201d);}<\/p>\n<p>}<\/p>\n<p><strong>class<\/strong>BabyDog\u00a0<strong>extends<\/strong>\u00a0Dog{<\/p>\n<p><strong>void<\/strong>\u00a0weep(){System.out.println(\u201cweeping\u2026\u201d);}<\/p>\n<p>}<\/p>\n<p><strong>class<\/strong>\u00a0TestInheritance2{<\/p>\n<p><strong>publicstatic<\/strong>\u00a0<strong>void<\/strong>\u00a0main(String\u00a0args[]){<\/p>\n<p>BabyDog\u00a0d=<strong>new<\/strong>\u00a0BabyDog();<\/p>\n<p>weep();<\/p>\n<p>d.bark();<\/p>\n<p>eat();<\/p>\n<p>}}<\/p>\n<p><strong>Output:<\/strong><\/p>\n<p>weeping\u2026barking\u2026eating\u2026<\/p>\n<p style=\"text-align: center;\"><strong><a href=\"https:\/\/bit.ly\/3ELmCiA\" target=\"_blank\" rel=\"noopener\">Learn to code from industry experts! Enroll here!<\/a><\/strong><\/p>\n<h3><strong>Hierarchical Inheritance\u00a0<\/strong><\/h3>\n<p>When two or more classes inherits a single class, it is known as\u00a0hierarchical inheritance. In the example given below, Dog and Cat classes inherits the Animal class, so there is hierarchical inheritance.<\/p>\n<p><strong>File: TestInheritance3.java<\/strong><\/p>\n<p><strong>class<\/strong>Animal{<\/p>\n<p><strong>void<\/strong>\u00a0eat(){System.out.println(\u201ceating\u2026\u201d);}<\/p>\n<p>}<\/p>\n<p><strong>class<\/strong>\u00a0Dog\u00a0<strong>extends<\/strong>\u00a0Animal{<\/p>\n<p><strong>void<\/strong>bark(){System.out.println(\u201cbarking\u2026\u201d);}<\/p>\n<p>}<\/p>\n<p><strong>class<\/strong>Cat\u00a0<strong>extends<\/strong>\u00a0Animal{<\/p>\n<p><strong>void<\/strong>\u00a0meow(){System.out.println(\u201cmeowing\u2026\u201d);}<\/p>\n<p>}<\/p>\n<p><strong>class<\/strong>\u00a0TestInheritance3{<strong>publicstatic<\/strong>\u00a0<strong>void<\/strong>\u00a0main(String\u00a0args[]){<\/p>\n<p>Cat\u00a0c=<strong>new<\/strong>\u00a0Cat();<\/p>\n<p>meow();<\/p>\n<p>c.eat();<\/p>\n<p>\/\/c.bark();\/\/C.T.Error<\/p>\n<p>}}<\/p>\n<p><strong>Output:<\/strong><\/p>\n<p>meowing\u2026eating\u2026<\/p>\n<h3><strong>Multiple Inheritance<\/strong><\/h3>\n<p>Java does not support multiple inheritance. Multiple inheritance means a class derived from more than one direct super class. This increases complexities and ambiguity in the relationship among classes. The problem is clearly visible if we consider what happens in function overriding. Suppose there are two classes, A and B, each defining a function called\u00a0<em>func()<\/em>. Now, let\u2019s say we define another class, C, which inherits both from A and B (multiple inheritance), but let\u2019s say this class does not override the function called\u00a0<em>func()<\/em>.<\/p>\n<p>Now, if we do something like the following:<\/p>\n<p>C c = new C();c.func();<\/p>\n<p>Can we determine which member function\u00a0<em>func()<\/em>\u00a0is invoked? Is it function defined by class A or class B? As we can see, the class C inherits this function doubly from both A and B. This creates ambiguity and the compiler is in a fix to resolve the issue. There is solution to this problem, but it\u2019s extremely complex; therefore, Java decided to stay away from the cause of the problem by not allowing multiple inheritance.<\/p>\n<h4><strong>Multiple Inheritance with Interfaces<\/strong><\/h4>\n<p>Although Java does not allow multiple inheritance, it allows a multiple implementation of interfaces. So, in a way the idea is still there. Now, what is an interface?<\/p>\n<p>An interface describes a set of methods but does not provide any concrete implementation for all methods. We can implement the interface with the help of a class which provides the concrete implementation of the method. In this way, a class can implement more than one interface and therefore can provide a concrete implementation of methods derived from one or more interfaces. The class that implements one or more interfaces forms a\u00a0<em>is-a<\/em>\u00a0relationship with the interface type. This also means that objects instantiated from the class are guaranteed to provide the functionality declared by the interface. Any subclass derived from this class also provides the same functionality.<\/p>\n<p>Interfaces are especially useful for providing a common functionality to a number of possibly unrelated classes. Therefore, the object of classes that implement same interface can respond to method calls described in all of the interfaces.<\/p>\n<p>From Java 8, interfaces support default methods with its full implementation. As we know, a class can implement more than one interface; therefore, if multiple interfaces contain a default method with the same method signature, the implemented class should specify which particular method to use or override.<\/p>\n<p>Example<\/p>\n<p><strong>package<\/strong>\u00a0com.mano.examples;<\/p>\n<p><strong>public interface<\/strong>\u00a0Interface1 {<\/p>\n<p><strong>default void<\/strong>\u00a0func(){<\/p>\n<p>System.<strong><em>out<\/em><\/strong>.println(<strong>\u201cfrom interface 1\u201d<\/strong>);<\/p>\n<p>}}<\/p>\n<p><strong>package<\/strong>\u00a0com.mano.examples;<strong>public interface<\/strong>\u00a0Interface2 {<\/p>\n<p><strong>default void<\/strong>\u00a0func(){<\/p>\n<p>System.<strong><em>out<\/em><\/strong>.println(<strong>\u201cfrom interface 2\u201d<\/strong>);<\/p>\n<p>}}<\/p>\n<p><strong>package<\/strong>\u00a0com.mano.examples;<strong>public class<\/strong>\u00a0MyClass\u00a0<strong>implements<\/strong>\u00a0Interface1, Interface2 {<\/p>\n<p><strong>public void<\/strong>\u00a0func(){\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<em>\/\/ Invoking Interface1 func() method<\/em><\/p>\n<p>Interface1.<strong>super<\/strong>.func();\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<em>\/\/ Invoking Interface2 func() method<\/em>\u00a0\u00a0\u00a0\u00a0\u00a0 Interface2.<strong>super<\/strong>.func();<\/p>\n<p>}<\/p>\n<p><strong>public static void<\/strong>\u00a0main(String[] args){<\/p>\n<p>MyClass c=<strong>new<\/strong>\u00a0MyClass();\u00a0\u00a0\u00a0\u00a0\u00a0 c.func();<\/p>\n<p>}<\/p>\n<p style=\"text-align: center;\"><strong><a href=\"https:\/\/bit.ly\/3ELmCiA\" target=\"_blank\" rel=\"noopener\">Learn Coding in your Language! Enroll Here!<\/a><\/strong><\/p>\n<p><strong>Why is it important to choose Entri?<\/strong><\/p>\n<ul>\n<li>Excellent online platform for all the Competitive Exams.<\/li>\n<li>Provides updated materials created by the Entri Experts.<\/li>\n<li>Entri provides a best platform with full- length mock tests including previous year question papers.<\/li>\n<li>You can download the app for free and join the required classes.<\/li>\n<li>Entri wishes you all the best for your examinations and future endeavours.<\/li>\n<\/ul>\n<p><strong>\u201cYOU DON\u2019T HAVE TO BE GREAT TO START, BUT YOU HAVE TO START TO BE GREAT.\u201d<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Inheritance in Java\u00a0is a mechanism in which one object acquires all the properties and behaviors of a parent object. It is an important part of\u00a0OOPs\u00a0(Object Oriented programming system). The idea behind inheritance in Java is that you can create new\u00a0classes\u00a0that are built upon existing classes. When you inherit from an existing class, you can reuse [&hellip;]<\/p>\n","protected":false},"author":55,"featured_media":25539698,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[802,558,1882],"tags":[],"class_list":["post-25539696","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-articles","category-general-knowledge","category-java-programming"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Introduction To Inheritance In Java - Entri Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/entri.app\/blog\/introduction-to-inheritance-in-java\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Introduction To Inheritance In Java - Entri Blog\" \/>\n<meta property=\"og:description\" content=\"Inheritance in Java\u00a0is a mechanism in which one object acquires all the properties and behaviors of a parent object. It is an important part of\u00a0OOPs\u00a0(Object Oriented programming system). The idea behind inheritance in Java is that you can create new\u00a0classes\u00a0that are built upon existing classes. When you inherit from an existing class, you can reuse [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/entri.app\/blog\/introduction-to-inheritance-in-java\/\" \/>\n<meta property=\"og:site_name\" content=\"Entri Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/entri.me\/\" \/>\n<meta property=\"article:published_time\" content=\"2022-08-25T20:05:16+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-11-19T09:03:24+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/08\/Introduction-To-Inheritance-In-Java.png\" \/>\n\t<meta property=\"og:image:width\" content=\"820\" \/>\n\t<meta property=\"og:image:height\" content=\"615\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Ayesha Surayya\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@entri_app\" \/>\n<meta name=\"twitter:site\" content=\"@entri_app\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Ayesha Surayya\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/entri.app\/blog\/introduction-to-inheritance-in-java\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/entri.app\/blog\/introduction-to-inheritance-in-java\/\"},\"author\":{\"name\":\"Ayesha Surayya\",\"@id\":\"https:\/\/entri.app\/blog\/#\/schema\/person\/568cc9d6e77fd5d01033b61c88343097\"},\"headline\":\"Introduction To Inheritance In Java\",\"datePublished\":\"2022-08-25T20:05:16+00:00\",\"dateModified\":\"2022-11-19T09:03:24+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/entri.app\/blog\/introduction-to-inheritance-in-java\/\"},\"wordCount\":1045,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/entri.app\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/entri.app\/blog\/introduction-to-inheritance-in-java\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/08\/Introduction-To-Inheritance-In-Java.png\",\"articleSection\":[\"Articles\",\"General Knowledge\",\"Java Programming\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/entri.app\/blog\/introduction-to-inheritance-in-java\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/entri.app\/blog\/introduction-to-inheritance-in-java\/\",\"url\":\"https:\/\/entri.app\/blog\/introduction-to-inheritance-in-java\/\",\"name\":\"Introduction To Inheritance In Java - Entri Blog\",\"isPartOf\":{\"@id\":\"https:\/\/entri.app\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/entri.app\/blog\/introduction-to-inheritance-in-java\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/entri.app\/blog\/introduction-to-inheritance-in-java\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/08\/Introduction-To-Inheritance-In-Java.png\",\"datePublished\":\"2022-08-25T20:05:16+00:00\",\"dateModified\":\"2022-11-19T09:03:24+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/entri.app\/blog\/introduction-to-inheritance-in-java\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/entri.app\/blog\/introduction-to-inheritance-in-java\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/entri.app\/blog\/introduction-to-inheritance-in-java\/#primaryimage\",\"url\":\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/08\/Introduction-To-Inheritance-In-Java.png\",\"contentUrl\":\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/08\/Introduction-To-Inheritance-In-Java.png\",\"width\":820,\"height\":615,\"caption\":\"Introduction To Inheritance In Java\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/entri.app\/blog\/introduction-to-inheritance-in-java\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/entri.app\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Entri Skilling\",\"item\":\"https:\/\/entri.app\/blog\/category\/entri-skilling\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Java Programming\",\"item\":\"https:\/\/entri.app\/blog\/category\/entri-skilling\/java-programming\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Introduction To Inheritance In Java\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/entri.app\/blog\/#website\",\"url\":\"https:\/\/entri.app\/blog\/\",\"name\":\"Entri Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/entri.app\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/entri.app\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/entri.app\/blog\/#organization\",\"name\":\"Entri App\",\"url\":\"https:\/\/entri.app\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/entri.app\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2019\/10\/Entri-Logo-1.png\",\"contentUrl\":\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2019\/10\/Entri-Logo-1.png\",\"width\":989,\"height\":446,\"caption\":\"Entri App\"},\"image\":{\"@id\":\"https:\/\/entri.app\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/entri.me\/\",\"https:\/\/x.com\/entri_app\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/entri.app\/blog\/#\/schema\/person\/568cc9d6e77fd5d01033b61c88343097\",\"name\":\"Ayesha Surayya\",\"url\":\"https:\/\/entri.app\/blog\/author\/ayesha-surayya\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Introduction To Inheritance In Java - Entri Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/entri.app\/blog\/introduction-to-inheritance-in-java\/","og_locale":"en_US","og_type":"article","og_title":"Introduction To Inheritance In Java - Entri Blog","og_description":"Inheritance in Java\u00a0is a mechanism in which one object acquires all the properties and behaviors of a parent object. It is an important part of\u00a0OOPs\u00a0(Object Oriented programming system). The idea behind inheritance in Java is that you can create new\u00a0classes\u00a0that are built upon existing classes. When you inherit from an existing class, you can reuse [&hellip;]","og_url":"https:\/\/entri.app\/blog\/introduction-to-inheritance-in-java\/","og_site_name":"Entri Blog","article_publisher":"https:\/\/www.facebook.com\/entri.me\/","article_published_time":"2022-08-25T20:05:16+00:00","article_modified_time":"2022-11-19T09:03:24+00:00","og_image":[{"width":820,"height":615,"url":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/08\/Introduction-To-Inheritance-In-Java.png","type":"image\/png"}],"author":"Ayesha Surayya","twitter_card":"summary_large_image","twitter_creator":"@entri_app","twitter_site":"@entri_app","twitter_misc":{"Written by":"Ayesha Surayya","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/entri.app\/blog\/introduction-to-inheritance-in-java\/#article","isPartOf":{"@id":"https:\/\/entri.app\/blog\/introduction-to-inheritance-in-java\/"},"author":{"name":"Ayesha Surayya","@id":"https:\/\/entri.app\/blog\/#\/schema\/person\/568cc9d6e77fd5d01033b61c88343097"},"headline":"Introduction To Inheritance In Java","datePublished":"2022-08-25T20:05:16+00:00","dateModified":"2022-11-19T09:03:24+00:00","mainEntityOfPage":{"@id":"https:\/\/entri.app\/blog\/introduction-to-inheritance-in-java\/"},"wordCount":1045,"commentCount":0,"publisher":{"@id":"https:\/\/entri.app\/blog\/#organization"},"image":{"@id":"https:\/\/entri.app\/blog\/introduction-to-inheritance-in-java\/#primaryimage"},"thumbnailUrl":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/08\/Introduction-To-Inheritance-In-Java.png","articleSection":["Articles","General Knowledge","Java Programming"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/entri.app\/blog\/introduction-to-inheritance-in-java\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/entri.app\/blog\/introduction-to-inheritance-in-java\/","url":"https:\/\/entri.app\/blog\/introduction-to-inheritance-in-java\/","name":"Introduction To Inheritance In Java - Entri Blog","isPartOf":{"@id":"https:\/\/entri.app\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/entri.app\/blog\/introduction-to-inheritance-in-java\/#primaryimage"},"image":{"@id":"https:\/\/entri.app\/blog\/introduction-to-inheritance-in-java\/#primaryimage"},"thumbnailUrl":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/08\/Introduction-To-Inheritance-In-Java.png","datePublished":"2022-08-25T20:05:16+00:00","dateModified":"2022-11-19T09:03:24+00:00","breadcrumb":{"@id":"https:\/\/entri.app\/blog\/introduction-to-inheritance-in-java\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/entri.app\/blog\/introduction-to-inheritance-in-java\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/entri.app\/blog\/introduction-to-inheritance-in-java\/#primaryimage","url":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/08\/Introduction-To-Inheritance-In-Java.png","contentUrl":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/08\/Introduction-To-Inheritance-In-Java.png","width":820,"height":615,"caption":"Introduction To Inheritance In Java"},{"@type":"BreadcrumbList","@id":"https:\/\/entri.app\/blog\/introduction-to-inheritance-in-java\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/entri.app\/blog\/"},{"@type":"ListItem","position":2,"name":"Entri Skilling","item":"https:\/\/entri.app\/blog\/category\/entri-skilling\/"},{"@type":"ListItem","position":3,"name":"Java Programming","item":"https:\/\/entri.app\/blog\/category\/entri-skilling\/java-programming\/"},{"@type":"ListItem","position":4,"name":"Introduction To Inheritance In Java"}]},{"@type":"WebSite","@id":"https:\/\/entri.app\/blog\/#website","url":"https:\/\/entri.app\/blog\/","name":"Entri Blog","description":"","publisher":{"@id":"https:\/\/entri.app\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/entri.app\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/entri.app\/blog\/#organization","name":"Entri App","url":"https:\/\/entri.app\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/entri.app\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2019\/10\/Entri-Logo-1.png","contentUrl":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2019\/10\/Entri-Logo-1.png","width":989,"height":446,"caption":"Entri App"},"image":{"@id":"https:\/\/entri.app\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/entri.me\/","https:\/\/x.com\/entri_app"]},{"@type":"Person","@id":"https:\/\/entri.app\/blog\/#\/schema\/person\/568cc9d6e77fd5d01033b61c88343097","name":"Ayesha Surayya","url":"https:\/\/entri.app\/blog\/author\/ayesha-surayya\/"}]}},"_links":{"self":[{"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/posts\/25539696","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/users\/55"}],"replies":[{"embeddable":true,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/comments?post=25539696"}],"version-history":[{"count":4,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/posts\/25539696\/revisions"}],"predecessor-version":[{"id":25547300,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/posts\/25539696\/revisions\/25547300"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/media\/25539698"}],"wp:attachment":[{"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/media?parent=25539696"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/categories?post=25539696"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/tags?post=25539696"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}