{"id":112,"date":"2026-06-02T12:05:23","date_gmt":"2026-06-02T12:05:23","guid":{"rendered":"https:\/\/gigz.pk\/javaapp\/?post_type=lesson&#038;p=112"},"modified":"2026-06-06T07:24:10","modified_gmt":"2026-06-06T07:24:10","slug":"inheritance","status":"publish","type":"lesson","link":"https:\/\/gigz.pk\/javaapp\/?lesson=inheritance","title":{"rendered":"Inheritance"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Inheritance is one of the core principles of Object-Oriented Programming (OOP) in Java. It allows one class to acquire the properties and behaviors of another class. By using inheritance, developers can reuse existing code, reduce duplication, and create a logical relationship between classes.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Inheritance helps build applications that are easier to maintain, extend, and manage. It is widely used in Java development, Android applications, enterprise software, and large-scale systems.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What is Inheritance in Java?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Inheritance is the process through which one class inherits fields and methods from another class.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The class being inherited from is called the <strong>parent class<\/strong>, <strong>superclass<\/strong>, or <strong>base class<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The class that inherits is called the <strong>child class<\/strong>, <strong>subclass<\/strong>, or <strong>derived class<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Inheritance creates an <strong>&#8220;is-a&#8221; relationship<\/strong> between classes.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Car is a Vehicle<\/li>\n\n\n\n<li>Dog is an Animal<\/li>\n\n\n\n<li>Student is a Person<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">These relationships can be represented using inheritance.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Why Use Inheritance?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Inheritance provides several advantages:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Promotes code reusability<\/li>\n\n\n\n<li>Reduces code duplication<\/li>\n\n\n\n<li>Improves maintainability<\/li>\n\n\n\n<li>Simplifies application development<\/li>\n\n\n\n<li>Supports method overriding<\/li>\n\n\n\n<li>Creates logical class hierarchies<\/li>\n\n\n\n<li>Enhances Object-Oriented Design<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">It is one of the most important concepts in Java programming.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Syntax of Inheritance<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Java uses the <code>extends<\/code> keyword to implement inheritance.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>class Parent {\n\n    \/\/ parent class members\n\n}\n\nclass Child extends Parent {\n\n    \/\/ child class members\n\n}\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The child class automatically gains access to accessible members of the parent class.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Basic Example of Inheritance<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>class Animal {\n\n    void eat() {\n\n        System.out.println(\"Animal is eating\");\n\n    }\n\n}\n\nclass Dog extends Animal {\n\n}\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Using the classes:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public class Main {\n\n    public static void main(String&#91;] args) {\n\n        Dog dog = new Dog();\n\n        dog.eat();\n\n    }\n\n}\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Animal is eating\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The Dog class inherits the eat() method from the Animal class.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Understanding Parent and Child Classes<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>class Person {\n\n    String name;\n\n}\n<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>class Student extends Person {\n\n    int rollNumber;\n\n}\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The Student class automatically inherits the name variable from the Person class.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Usage:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Student student = new Student();\n\nstudent.name = \"Ali\";\nstudent.rollNumber = 101;\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The object can access both inherited and its own members.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Types of Inheritance in Java<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Java supports several inheritance concepts.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Single Inheritance<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">A child class inherits from one parent class.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>class Animal {\n\n}\n\nclass Dog extends Animal {\n\n}\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This is the most common form of inheritance.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Multilevel Inheritance<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">A class inherits from a child class that already inherited from another class.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>class Animal {\n\n}\n\nclass Dog extends Animal {\n\n}\n\nclass Puppy extends Dog {\n\n}\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Puppy inherits features from both Dog and Animal.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Hierarchical Inheritance<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Multiple child classes inherit from the same parent class.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>class Animal {\n\n}\n\nclass Dog extends Animal {\n\n}\n\nclass Cat extends Animal {\n\n}\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Both Dog and Cat inherit from Animal.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Why Java Does Not Support Multiple Inheritance with Classes<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Java does not allow multiple inheritance through classes because it can create ambiguity problems.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Incorrect:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>class A {\n\n}\n\nclass B {\n\n}\n\nclass C extends A, B {\n\n}\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This is not allowed in Java.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Instead, Java uses interfaces to achieve multiple inheritance behavior.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Inherited Members<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A child class can inherit:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Variables<\/li>\n\n\n\n<li>Methods<\/li>\n\n\n\n<li>Constructors (through constructor chaining)<\/li>\n\n\n\n<li>Protected members<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>class Vehicle {\n\n    String brand = \"Toyota\";\n\n    void start() {\n\n        System.out.println(\"Vehicle Started\");\n\n    }\n\n}\n<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>class Car extends Vehicle {\n\n}\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Using the object:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Car car = new Car();\n\nSystem.out.println(car.brand);\n\ncar.start();\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Toyota\nVehicle Started\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The child class gains access to inherited members.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Method Inheritance Example<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>class Person {\n\n    void display() {\n\n        System.out.println(\"Person Information\");\n\n    }\n\n}\n<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>class Student extends Person {\n\n}\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Using the method:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Student student = new Student();\n\nstudent.display();\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Person Information\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Methods can be reused through inheritance.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">The super Keyword<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>super<\/code> keyword refers to the parent class.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It is used to:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Access parent variables<\/li>\n\n\n\n<li>Call parent methods<\/li>\n\n\n\n<li>Invoke parent constructors<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>class Animal {\n\n    void sound() {\n\n        System.out.println(\"Animal Sound\");\n\n    }\n\n}\n<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>class Dog extends Animal {\n\n    void display() {\n\n        super.sound();\n\n    }\n\n}\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Animal Sound\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The super keyword provides access to parent class functionality.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Constructor Inheritance<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Constructors are not directly inherited, but parent constructors can be called using super().<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>class Person {\n\n    Person() {\n\n        System.out.println(\"Person Constructor\");\n\n    }\n\n}\n<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>class Student extends Person {\n\n    Student() {\n\n        super();\n\n    }\n\n}\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Person Constructor\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This helps initialize parent class data.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Real-World Example<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Employee management system:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>class Employee {\n\n    String company = \"ABC Ltd\";\n\n    void work() {\n\n        System.out.println(\"Employee Working\");\n\n    }\n\n}\n<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>class Manager extends Employee {\n\n    void manage() {\n\n        System.out.println(\"Managing Team\");\n\n    }\n\n}\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Usage:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Manager manager = new Manager();\n\nSystem.out.println(manager.company);\n\nmanager.work();\n\nmanager.manage();\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ABC Ltd\nEmployee Working\nManaging Team\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Inheritance reduces duplicate code and improves efficiency.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Benefits of Inheritance<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Code Reusability<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Existing code can be reused instead of rewritten.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Reduced Redundancy<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Common functionality remains in the parent class.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Easier Maintenance<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Updates made in the parent class automatically affect child classes.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Better Organization<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Classes can be arranged logically.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Supports Polymorphism<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Inheritance serves as the foundation for polymorphism.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Faster Development<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Developers can extend existing classes rather than creating everything from scratch.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Applications of Inheritance<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Inheritance is used in:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Android application development<\/li>\n\n\n\n<li>Banking systems<\/li>\n\n\n\n<li>Hospital management software<\/li>\n\n\n\n<li>E-commerce platforms<\/li>\n\n\n\n<li>Educational systems<\/li>\n\n\n\n<li>Game development<\/li>\n\n\n\n<li>Enterprise software<\/li>\n\n\n\n<li>Inventory management systems<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">It plays a major role in modern software architecture.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Common Beginner Mistakes<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Confusing Inheritance with Object Creation<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Inheritance creates relationships between classes, not objects.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Using Private Members Directly<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Private members cannot be inherited directly.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Incorrect Class Hierarchies<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Inheritance should represent an actual &#8220;is-a&#8221; relationship.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Incorrect example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Car extends Engine\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">A car is not an engine.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Forgetting the extends Keyword<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Without extends, inheritance does not occur.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Best Practices<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">When using inheritance:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Use inheritance only for true &#8220;is-a&#8221; relationships<\/li>\n\n\n\n<li>Avoid unnecessary inheritance levels<\/li>\n\n\n\n<li>Keep parent classes generic<\/li>\n\n\n\n<li>Use protected access when appropriate<\/li>\n\n\n\n<li>Combine inheritance with encapsulation<\/li>\n\n\n\n<li>Prefer composition when inheritance is not suitable<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">These practices improve software design and maintainability.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Importance of Inheritance<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Inheritance is important because it:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Promotes code reuse<\/li>\n\n\n\n<li>Simplifies software development<\/li>\n\n\n\n<li>Reduces duplication<\/li>\n\n\n\n<li>Supports scalability<\/li>\n\n\n\n<li>Enables advanced OOP concepts<\/li>\n\n\n\n<li>Improves application structure<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">It is a fundamental building block of Object-Oriented Programming.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Inheritance in Java allows a child class to acquire the properties and behaviors of a parent class. By using the extends keyword, developers can create reusable, organized, and maintainable code while reducing duplication. Mastering inheritance is essential for understanding Object-Oriented Programming and building professional Java, Android, and enterprise software applications.<\/p>\n\n\n<div class=\"yoast-breadcrumbs\"><span><span><a href=\"https:\/\/gigz.pk\/javaapp\">Home<\/a><\/span> \u00bb <span class=\"breadcrumb_last\" aria-current=\"page\">Intermediate Java > Object-Oriented Programming > Inheritance<\/span><\/span><\/div>\n\n\n<div class=\"schema-faq wp-block-yoast-faq-block\"><div class=\"schema-faq-section\" id=\"faq-question-1780730699670\"><strong class=\"schema-faq-question\"><\/strong> <p class=\"schema-faq-answer\"><\/p> <\/div> <\/div>\n","protected":false},"menu_order":29,"template":"","class_list":["post-112","lesson","type-lesson","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Inheritance - Learn Java used for Apps with GiGz.PK<\/title>\n<meta name=\"description\" content=\"Learn Java inheritance \u2014 parent and child classes, extends keyword, types of inheritance, and real-world OOP examples explained.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/gigz.pk\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Inheritance - Learn Java used for Apps with GiGz.PK\" \/>\n<meta property=\"og:description\" content=\"Learn Java inheritance \u2014 parent and child classes, extends keyword, types of inheritance, and real-world OOP examples explained.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/gigz.pk\/\" \/>\n<meta property=\"og:site_name\" content=\"Learn Java used for Apps with GiGz.PK\" \/>\n<meta property=\"article:modified_time\" content=\"2026-06-06T07:24:10+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":[\"WebPage\",\"FAQPage\"],\"@id\":\"https:\\\/\\\/gigz.pk\\\/javaapp\\\/?lesson=inheritance\",\"url\":\"https:\\\/\\\/gigz.pk\\\/\",\"name\":\"Inheritance - Learn Java used for Apps with GiGz.PK\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/gigz.pk\\\/javaapp\\\/#website\"},\"datePublished\":\"2026-06-02T12:05:23+00:00\",\"dateModified\":\"2026-06-06T07:24:10+00:00\",\"description\":\"Learn Java inheritance \u2014 parent and child classes, extends keyword, types of inheritance, and real-world OOP examples explained.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/gigz.pk\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/gigz.pk\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/gigz.pk\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/gigz.pk\\\/javaapp\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Intermediate Java > Object-Oriented Programming > Inheritance\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/gigz.pk\\\/javaapp\\\/#website\",\"url\":\"https:\\\/\\\/gigz.pk\\\/javaapp\\\/\",\"name\":\"Learn Java used for Apps with GiGz.PK\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/gigz.pk\\\/javaapp\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Inheritance - Learn Java used for Apps with GiGz.PK","description":"Learn Java inheritance \u2014 parent and child classes, extends keyword, types of inheritance, and real-world OOP examples explained.","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:\/\/gigz.pk\/","og_locale":"en_US","og_type":"article","og_title":"Inheritance - Learn Java used for Apps with GiGz.PK","og_description":"Learn Java inheritance \u2014 parent and child classes, extends keyword, types of inheritance, and real-world OOP examples explained.","og_url":"https:\/\/gigz.pk\/","og_site_name":"Learn Java used for Apps with GiGz.PK","article_modified_time":"2026-06-06T07:24:10+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":["WebPage","FAQPage"],"@id":"https:\/\/gigz.pk\/javaapp\/?lesson=inheritance","url":"https:\/\/gigz.pk\/","name":"Inheritance - Learn Java used for Apps with GiGz.PK","isPartOf":{"@id":"https:\/\/gigz.pk\/javaapp\/#website"},"datePublished":"2026-06-02T12:05:23+00:00","dateModified":"2026-06-06T07:24:10+00:00","description":"Learn Java inheritance \u2014 parent and child classes, extends keyword, types of inheritance, and real-world OOP examples explained.","breadcrumb":{"@id":"https:\/\/gigz.pk\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/gigz.pk\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/gigz.pk\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/gigz.pk\/javaapp"},{"@type":"ListItem","position":2,"name":"Intermediate Java > Object-Oriented Programming > Inheritance"}]},{"@type":"WebSite","@id":"https:\/\/gigz.pk\/javaapp\/#website","url":"https:\/\/gigz.pk\/javaapp\/","name":"Learn Java used for Apps with GiGz.PK","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/gigz.pk\/javaapp\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/gigz.pk\/javaapp\/index.php?rest_route=\/wp\/v2\/lesson\/112","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gigz.pk\/javaapp\/index.php?rest_route=\/wp\/v2\/lesson"}],"about":[{"href":"https:\/\/gigz.pk\/javaapp\/index.php?rest_route=\/wp\/v2\/types\/lesson"}],"wp:attachment":[{"href":"https:\/\/gigz.pk\/javaapp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=112"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}