{"id":691,"date":"2025-05-18T18:44:07","date_gmt":"2025-05-18T18:44:07","guid":{"rendered":"https:\/\/buhave.com\/courses\/?p=691"},"modified":"2026-06-06T15:20:56","modified_gmt":"2026-06-06T15:20:56","slug":"inheritance","status":"publish","type":"post","link":"https:\/\/buhave.com\/courses\/oop\/inheritance\/","title":{"rendered":"Inheritance"},"content":{"rendered":"<h2>Concept of inheritance<\/h2>\n<p>Inheritance is a core concept in Object-Oriented Programming that allows one class (called the child or subclass) to acquire the properties and behaviors (fields and methods) of another class (called the parent or superclass). It promotes code reuse, hierarchy, and a clear organizational structure in complex software systems. In modern languages, developers also combine inheritance with interfaces, mixins, and composition to model complex systems more flexibly. While classic multiple inheritance is supported in a few languages (like Python), many languages (such as Java) rely on interfaces for multiple-type behavior without ambiguity. For a broad overview of OOP concepts, see <a href=\"https:\/\/buhave.com\/courses\/oop\/introduction-to-oop\/\" title=\"Introduction to OOP\">Introduction to OOP<\/a>.<\/p>\n<h3>Key Idea of Inheritance<\/h3>\n<ul>\n<li>A subclass inherits the fields and methods of its superclass<\/li>\n<li>The subclass can use, override, or extend the functionality of the superclass<\/li>\n<li>This allows shared behavior across multiple related classes, reducing code duplication<\/li>\n<\/ul>\n<p><strong>Types of Inheritance<\/strong><\/p>\n<ul>\n<li>Single Inheritance \u2013 A subclass inherits from one superclass<\/li>\n<li>Multiple Inheritance \u2013 A subclass inherits from more than one superclass (supported in languages like Python; Java uses interfaces to achieve similar behavior)<\/li>\n<li>Multilevel Inheritance \u2013 A subclass inherits from a class that is also a subclass of another class<\/li>\n<li>Hierarchical Inheritance \u2013 Multiple subclasses inherit from the same superclass<\/li>\n<li>Hybrid Inheritance \u2013 A combination of two or more types of inheritance<\/li>\n<\/ul>\n<p><strong>Benefits of Inheritance<\/strong><\/p>\n<ul>\n<li>Encourages code reuse by allowing common functionality to be defined once in a base class<\/li>\n<li>Improves maintainability and reduces redundancy<\/li>\n<li>Enables polymorphism, allowing objects to be treated as instances of their superclass<\/li>\n<li>Helps build modular and scalable applications<\/li>\n<\/ul>\n<p><strong>Inheritance and Method Overriding<\/strong><\/p>\n<ul>\n<li>A subclass can override methods of the superclass to provide specialized behavior<\/li>\n<li>This supports dynamic behavior and flexibility in object interactions<\/li>\n<\/ul>\n<p>This concept is closely related to polymorphism; learn more in the <a href=\"https:\/\/buhave.com\/courses\/oop\/polymorphism\/\" title=\"Polymorphism\">Polymorphism<\/a> guide.<\/p>\n<p><strong>Inheritance in Real-World Modeling<\/strong><\/p>\n<ul>\n<li>Example: A vehicle superclass with fields like speed and fuel<\/li>\n<li>Subclasses like car, truck, and bike inherit common behavior but also have specific features<\/li>\n<\/ul>\n<p>For a deeper discussion of relationships, see <a href=\"https:\/\/buhave.com\/courses\/oop\/object-relationships-and-design\/\" title=\"Object Relationships and Design\">Object Relationships and Design<\/a>.<\/p>\n<p>Inheritance forms the foundation for building a hierarchical structure of classes, promoting reuse, reducing complexity, and making software more extensible and easier to manage.<\/p>\n<h2>Base and Derived classes<\/h2>\n<p>Base and derived classes are fundamental components of inheritance in Object-Oriented Programming. They define a relationship where one class inherits properties and behaviors from another, allowing for code reuse and logical organization of related entities. For a broader overview of object-oriented concepts, see <a href=\"https:\/\/buhave.com\/courses\/oop\/introduction-to-oop\/\" title=\"Introduction to OOP\">Introduction to OOP<\/a>.<\/p>\n<h3>What is a Base Class?<\/h3>\n<ul>\n<li>A base class, also known as a superclass or parent class, is the general class from which other classes inherit<\/li>\n<li>It defines common fields and methods that are shared among derived classes<\/li>\n<li>Base classes provide a foundation of functionality that can be extended or reused<\/li>\n<li>Example: A person class with fields like name and age and methods like introduce<\/li>\n<\/ul>\n<p>For a deeper dive into related concepts like classes and objects, see <a href=\"https:\/\/buhave.com\/courses\/oop\/classes-and-objects\/\" title=\"Classes and Objects\">Classes and Objects<\/a>.<\/p>\n<h3>What is a Derived Class?<\/h3>\n<ul>\n<li>A derived class, also called a subclass or child class, is created by inheriting from a base class<\/li>\n<li>It automatically receives the fields and methods of the base class<\/li>\n<li>The derived class can also introduce new fields and methods or override base class methods<\/li>\n<li>Example: A Student class that inherits from person and adds student id and study()<\/li>\n<\/ul>\n<p>For more on derived classes and how they relate to the base class, see <a href=\"https:\/\/buhave.com\/courses\/oop\/classes-and-objects\/\" title=\"Classes and Objects\">Classes and Objects<\/a>.<\/p>\n<p><strong>Inheritance Relationship<\/strong><\/p>\n<ul>\n<li>Derived classes use the syntax of the language (like Extends Or to inherit from base classes<\/li>\n<li>This relationship creates an &#8220;is-a&#8221; association, meaning a Student is a Person<\/li>\n<li>Multiple derived classes can inherit from the same base class<\/li>\n<\/ul>\n<p>For a practical discussion of the relationships, see <a href=\"https:\/\/buhave.com\/courses\/oop\/object-relationships-and-design\/\" title=\"Object Relationships and Design\">Object Relationships and Design<\/a>.<\/p>\n<p><strong>Method Overriding<\/strong><\/p>\n<ul>\n<li>Derived classes can override methods of the base class to change or extend their behavior<\/li>\n<li>This is useful for customizing functionality while maintaining a shared interface<\/li>\n<\/ul>\n<p>This concept is closely related to polymorphism; learn more in the <a href=\"https:\/\/buhave.com\/courses\/oop\/polymorphism\/\" title=\"Polymorphism\">Polymorphism<\/a> guide.<\/p>\n<p><strong>Encapsulation and Access<\/strong><\/p>\n<ul>\n<li>Base class members can be protected or public to allow controlled access in derived classes<\/li>\n<li>Private members are not directly accessible by derived classes, preserving encapsulation<\/li>\n<\/ul>\n<p>For an in-depth look at access modifiers and encapsulation patterns, see <a href=\"https:\/\/buhave.com\/courses\/oop\/advanced-oop-concepts\/\" title=\"Advanced OOP Concepts\">Advanced OOP Concepts<\/a>.<\/p>\n<p><strong>Real-World Example<\/strong><\/p>\n<ul>\n<li>Animal (base class): has fields like species and age, and method Eat()<\/li>\n<li>Dog(derived class): inherits from Animal and adds method bark()<\/li>\n<li>Cat (derived class): inherits from Animal and adds method meow()<\/li>\n<\/ul>\n<p>These relationships are foundational to designs that emphasize polymorphism and extensibility; see <a href=\"https:\/\/buhave.com\/courses\/oop\/polymorphism\/\" title=\"Polymorphism\">Polymorphism<\/a> for examples.<\/p>\n<p>Base and derived classes promote efficient, reusable, and scalable code by leveraging inheritance. This structure enables developers to define generalized behavior once and extend it as needed in more specific contexts. In modern practice, these patterns are often combined with interfaces and composition to reduce coupling; for a broader overview of object-oriented concepts, see <a href=\"https:\/\/buhave.com\/courses\/oop\/introduction-to-oop\/\" title=\"Introduction to OOP\">Introduction to OOP<\/a>.<\/p>\n<h2>Method Overriding<\/h2>\n<h3>Method Overriding<\/h3>\n<p>Method overriding is an object-oriented programming feature that allows a subclass to provide a specific implementation of a method that is already defined in its superclass. It enables polymorphism and dynamic method dispatch, allowing objects to behave differently based on their actual types, even when referenced by a base type.<\/p>\n<p><strong>Definition and Purpose<\/strong><\/p>\n<ul>\n<li>Occurs when a derived class defines a method with the same name, return type, and parameters as a method in its base class<\/li>\n<li>Enables a subclass to provide a more specific or updated behavior for an inherited method<\/li>\n<li>Supports dynamic or runtime polymorphism<\/li>\n<\/ul>\n<p><strong>Requirements for Overriding<\/strong><\/p>\n<ul>\n<li>The method in the subclass must have the same signature (name and parameter list) as in the base class<\/li>\n<li>The method must be accessible to the subclass (usually Protected or Public)<\/li>\n<li>The base class method should be marked as Virtual (in languages like C++) or should be designed for overriding (like using @Override in Java)<\/li>\n<\/ul>\n<p><strong>Key Characteristics<\/strong><\/p>\n<ul>\n<li>Only instance (non-static) methods can be overridden<\/li>\n<li>Overridden methods in the subclass replace the behavior of the base class when called through a subclass object<\/li>\n<li>Polymorphism allows calling the overridden method using a reference to the base class, executing the derived class version<\/li>\n<\/ul>\n<p><strong>Benefits of Method Overriding<\/strong><\/p>\n<ul>\n<li>Provides flexibility to modify or enhance inherited behavior in derived classes<\/li>\n<li>Supports the Open\/Closed Principle by allowing extensions without modifying existing code<\/li>\n<li>Enables dynamic method resolution and customized responses in derived classes<\/li>\n<\/ul>\n<p><strong>Real-World Example<\/strong><\/p>\n<ul>\n<li>A Shape base class has a method draw()<\/li>\n<li>Subclasses like Circle and Rectangle override the draw() method to provide shape-specific drawing logic<\/li>\n<li>When calling draw() on a reference to Shape., the correct version executes based on the actual object type<\/li>\n<\/ul>\n<p><strong>Difference from Method Overloading<\/strong><\/p>\n<ul>\n<li>Overriding changes behavior in a subclass, while overloading defines multiple methods with the same name but different parameters in the same class<\/li>\n<\/ul>\n<p>Method overriding plays a crucial role in implementing polymorphism and extensible design. It allows subclasses to define their own versions of inherited methods, leading to more flexible and dynamic applications.<\/p>\n<h2>The super or base keyword<\/h2>\n<p>The super or base keyword is used in object-oriented programming to access the properties and methods of a parent class from within a child class. It plays a key role in inheritance by allowing a subclass to interact with its superclass.<\/p>\n<h3>Purpose and usage<\/h3>\n<ul>\n<li>Used to call the parent class constructor from the child class<\/li>\n<li>Allows the child class to access or extend methods and properties defined in the parent class<\/li>\n<li>Helps in reusing code and maintaining a clear class hierarchy<\/li>\n<\/ul>\n<p><strong>Super and Base in different languages<\/strong><\/p>\n<ul>\n<li>In Java and JavaScript, the keyword is super<\/li>\n<li>In C#, the equivalent keyword is base<\/li>\n<\/ul>\n<p><strong>Calling parent class constructor<\/strong><\/p>\n<ul>\n<li>super(arguments) or base(arguments) is used inside the subclass constructor to initialize the parent class<\/li>\n<li>This ensures the fields and setup from the parent class are properly applied before the subclass adds its own<\/li>\n<\/ul>\n<p><strong>Calling parent class methods<\/strong><\/p>\n<ul>\n<li>super. method Name() or base. method Name() is used to call a method from the parent class that is overridden in the subclass<\/li>\n<li>This is helpful when you want to preserve the original behavior and add more on top of it<\/li>\n<\/ul>\n<p><strong>Example scenario<\/strong><\/p>\n<ul>\n<li>A class Vehicle has a method start Engine<\/li>\n<li>A class Car extends Vehicle and overrides start Engine<\/li>\n<li>Inside Car\u2019s version of start Engine, calling super. start Engine() allows it to run the Vehicle\u2019s version first<\/li>\n<\/ul>\n<p><strong>Best practices<\/strong><\/p>\n<ul>\n<li>Use super or base for constructor chaining and avoiding code duplication<\/li>\n<li>Keep class hierarchies shallow and organized to make the use of these keywords simple and clear<\/li>\n<\/ul>\n<p>The super or base keyword provides a reliable way to access and build upon existing functionality from a parent class, encouraging code reuse and structured design in object-oriented systems.<\/p>\n<p>For language-specific nuances on super and base usage, see <a href=\"https:\/\/buhave.com\/courses\/oop\/advanced-oop-concepts\/\" title=\"Advanced OOP Concepts\">Advanced OOP Concepts<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Concept of inheritance Inheritance is a core concept in Object-Oriented Programming that allows one class (called the child or subclass) [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":692,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[14],"tags":[],"class_list":["post-691","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oop"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Inheritance - OOP Course<\/title>\n<meta name=\"description\" content=\"Inheritance allows a class to acquire properties and behaviors of another class, promoting code reuse and hierarchy.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/buhave.com\/courses\/oop\/inheritance\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Inheritance - OOP Course\" \/>\n<meta property=\"og:description\" content=\"Inheritance allows a class to acquire properties and behaviors of another class, promoting code reuse and hierarchy.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/buhave.com\/courses\/oop\/inheritance\/\" \/>\n<meta property=\"og:site_name\" content=\"BUHAVE\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/BeYouHave\/\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/naveedsafdarawan\/\" \/>\n<meta property=\"article:published_time\" content=\"2025-05-18T18:44:07+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-06-06T15:20:56+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/buhave.com\/courses\/wp-content\/uploads\/2025\/05\/Inheritance.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"author\" content=\"Naveed Safdar\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Naveed Safdar\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/oop\\\/inheritance\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/oop\\\/inheritance\\\/\"},\"author\":{\"name\":\"Naveed Safdar\",\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/#\\\/schema\\\/person\\\/04fe0254e118521c9fbb3da39de5acca\"},\"headline\":\"Inheritance\",\"datePublished\":\"2025-05-18T18:44:07+00:00\",\"dateModified\":\"2026-06-06T15:20:56+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/oop\\\/inheritance\\\/\"},\"wordCount\":1443,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/oop\\\/inheritance\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/buhave.com\\\/courses\\\/wp-content\\\/uploads\\\/2025\\\/05\\\/Inheritance.webp\",\"articleSection\":[\"OOP Course\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/buhave.com\\\/courses\\\/oop\\\/inheritance\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/oop\\\/inheritance\\\/\",\"url\":\"https:\\\/\\\/buhave.com\\\/courses\\\/oop\\\/inheritance\\\/\",\"name\":\"Inheritance - OOP Course\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/oop\\\/inheritance\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/oop\\\/inheritance\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/buhave.com\\\/courses\\\/wp-content\\\/uploads\\\/2025\\\/05\\\/Inheritance.webp\",\"datePublished\":\"2025-05-18T18:44:07+00:00\",\"dateModified\":\"2026-06-06T15:20:56+00:00\",\"description\":\"Inheritance allows a class to acquire properties and behaviors of another class, promoting code reuse and hierarchy.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/oop\\\/inheritance\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/buhave.com\\\/courses\\\/oop\\\/inheritance\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/oop\\\/inheritance\\\/#primaryimage\",\"url\":\"https:\\\/\\\/buhave.com\\\/courses\\\/wp-content\\\/uploads\\\/2025\\\/05\\\/Inheritance.webp\",\"contentUrl\":\"https:\\\/\\\/buhave.com\\\/courses\\\/wp-content\\\/uploads\\\/2025\\\/05\\\/Inheritance.webp\",\"width\":1200,\"height\":628,\"caption\":\"Inheritance\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/oop\\\/inheritance\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Courses\",\"item\":\"https:\\\/\\\/buhave.com\\\/courses\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"OOP Course\",\"item\":\"https:\\\/\\\/buhave.com\\\/courses\\\/learn\\\/oop\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Inheritance\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/#website\",\"url\":\"https:\\\/\\\/buhave.com\\\/courses\\\/\",\"name\":\"BUHAVE\",\"description\":\"Courses - Learn Online for Free\",\"publisher\":{\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/buhave.com\\\/courses\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/#organization\",\"name\":\"BUHAVE\",\"url\":\"https:\\\/\\\/buhave.com\\\/courses\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/buhave.com\\\/courses\\\/wp-content\\\/uploads\\\/2025\\\/03\\\/buhave-course.webp\",\"contentUrl\":\"https:\\\/\\\/buhave.com\\\/courses\\\/wp-content\\\/uploads\\\/2025\\\/03\\\/buhave-course.webp\",\"width\":375,\"height\":75,\"caption\":\"BUHAVE\"},\"image\":{\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/BeYouHave\\\/\",\"https:\\\/\\\/www.linkedin.com\\\/company\\\/buhave\",\"https:\\\/\\\/www.youtube.com\\\/@buhave\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/#\\\/schema\\\/person\\\/04fe0254e118521c9fbb3da39de5acca\",\"name\":\"Naveed Safdar\",\"description\":\"I\u2019m Naveed Safdar - SEO Manager with over 10 years of experience in SEO and Digital Marketing. I\u2019ve had the privilege of working with leading national and international companies including Grafdom, PakWheels, Systems Limited, Confiz, Educative, and Dubizzle Labs. My expertise spans technical SEO, content strategy, organic growth, and performance analytics - helping businesses improve visibility, traffic, and ROI.\",\"sameAs\":[\"https:\\\/\\\/www.linkedin.com\\\/in\\\/naveedsafdar\\\/\",\"https:\\\/\\\/www.facebook.com\\\/naveedsafdarawan\\\/\",\"https:\\\/\\\/www.youtube.com\\\/@naveedsafdar\"],\"url\":\"https:\\\/\\\/buhave.com\\\/courses\\\/author\\\/naveed-safdar\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Inheritance - OOP Course","description":"Inheritance allows a class to acquire properties and behaviors of another class, promoting code reuse and hierarchy.","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:\/\/buhave.com\/courses\/oop\/inheritance\/","og_locale":"en_US","og_type":"article","og_title":"Inheritance - OOP Course","og_description":"Inheritance allows a class to acquire properties and behaviors of another class, promoting code reuse and hierarchy.","og_url":"https:\/\/buhave.com\/courses\/oop\/inheritance\/","og_site_name":"BUHAVE","article_publisher":"https:\/\/www.facebook.com\/BeYouHave\/","article_author":"https:\/\/www.facebook.com\/naveedsafdarawan\/","article_published_time":"2025-05-18T18:44:07+00:00","article_modified_time":"2026-06-06T15:20:56+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/buhave.com\/courses\/wp-content\/uploads\/2025\/05\/Inheritance.webp","type":"image\/webp"}],"author":"Naveed Safdar","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Naveed Safdar","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/buhave.com\/courses\/oop\/inheritance\/#article","isPartOf":{"@id":"https:\/\/buhave.com\/courses\/oop\/inheritance\/"},"author":{"name":"Naveed Safdar","@id":"https:\/\/buhave.com\/courses\/#\/schema\/person\/04fe0254e118521c9fbb3da39de5acca"},"headline":"Inheritance","datePublished":"2025-05-18T18:44:07+00:00","dateModified":"2026-06-06T15:20:56+00:00","mainEntityOfPage":{"@id":"https:\/\/buhave.com\/courses\/oop\/inheritance\/"},"wordCount":1443,"commentCount":0,"publisher":{"@id":"https:\/\/buhave.com\/courses\/#organization"},"image":{"@id":"https:\/\/buhave.com\/courses\/oop\/inheritance\/#primaryimage"},"thumbnailUrl":"https:\/\/buhave.com\/courses\/wp-content\/uploads\/2025\/05\/Inheritance.webp","articleSection":["OOP Course"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/buhave.com\/courses\/oop\/inheritance\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/buhave.com\/courses\/oop\/inheritance\/","url":"https:\/\/buhave.com\/courses\/oop\/inheritance\/","name":"Inheritance - OOP Course","isPartOf":{"@id":"https:\/\/buhave.com\/courses\/#website"},"primaryImageOfPage":{"@id":"https:\/\/buhave.com\/courses\/oop\/inheritance\/#primaryimage"},"image":{"@id":"https:\/\/buhave.com\/courses\/oop\/inheritance\/#primaryimage"},"thumbnailUrl":"https:\/\/buhave.com\/courses\/wp-content\/uploads\/2025\/05\/Inheritance.webp","datePublished":"2025-05-18T18:44:07+00:00","dateModified":"2026-06-06T15:20:56+00:00","description":"Inheritance allows a class to acquire properties and behaviors of another class, promoting code reuse and hierarchy.","breadcrumb":{"@id":"https:\/\/buhave.com\/courses\/oop\/inheritance\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/buhave.com\/courses\/oop\/inheritance\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/buhave.com\/courses\/oop\/inheritance\/#primaryimage","url":"https:\/\/buhave.com\/courses\/wp-content\/uploads\/2025\/05\/Inheritance.webp","contentUrl":"https:\/\/buhave.com\/courses\/wp-content\/uploads\/2025\/05\/Inheritance.webp","width":1200,"height":628,"caption":"Inheritance"},{"@type":"BreadcrumbList","@id":"https:\/\/buhave.com\/courses\/oop\/inheritance\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Courses","item":"https:\/\/buhave.com\/courses\/"},{"@type":"ListItem","position":2,"name":"OOP Course","item":"https:\/\/buhave.com\/courses\/learn\/oop\/"},{"@type":"ListItem","position":3,"name":"Inheritance"}]},{"@type":"WebSite","@id":"https:\/\/buhave.com\/courses\/#website","url":"https:\/\/buhave.com\/courses\/","name":"BUHAVE","description":"Courses - Learn Online for Free","publisher":{"@id":"https:\/\/buhave.com\/courses\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/buhave.com\/courses\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/buhave.com\/courses\/#organization","name":"BUHAVE","url":"https:\/\/buhave.com\/courses\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/buhave.com\/courses\/#\/schema\/logo\/image\/","url":"https:\/\/buhave.com\/courses\/wp-content\/uploads\/2025\/03\/buhave-course.webp","contentUrl":"https:\/\/buhave.com\/courses\/wp-content\/uploads\/2025\/03\/buhave-course.webp","width":375,"height":75,"caption":"BUHAVE"},"image":{"@id":"https:\/\/buhave.com\/courses\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/BeYouHave\/","https:\/\/www.linkedin.com\/company\/buhave","https:\/\/www.youtube.com\/@buhave"]},{"@type":"Person","@id":"https:\/\/buhave.com\/courses\/#\/schema\/person\/04fe0254e118521c9fbb3da39de5acca","name":"Naveed Safdar","description":"I\u2019m Naveed Safdar - SEO Manager with over 10 years of experience in SEO and Digital Marketing. I\u2019ve had the privilege of working with leading national and international companies including Grafdom, PakWheels, Systems Limited, Confiz, Educative, and Dubizzle Labs. My expertise spans technical SEO, content strategy, organic growth, and performance analytics - helping businesses improve visibility, traffic, and ROI.","sameAs":["https:\/\/www.linkedin.com\/in\/naveedsafdar\/","https:\/\/www.facebook.com\/naveedsafdarawan\/","https:\/\/www.youtube.com\/@naveedsafdar"],"url":"https:\/\/buhave.com\/courses\/author\/naveed-safdar\/"}]}},"_links":{"self":[{"href":"https:\/\/buhave.com\/courses\/wp-json\/wp\/v2\/posts\/691","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/buhave.com\/courses\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/buhave.com\/courses\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/buhave.com\/courses\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/buhave.com\/courses\/wp-json\/wp\/v2\/comments?post=691"}],"version-history":[{"count":2,"href":"https:\/\/buhave.com\/courses\/wp-json\/wp\/v2\/posts\/691\/revisions"}],"predecessor-version":[{"id":1188,"href":"https:\/\/buhave.com\/courses\/wp-json\/wp\/v2\/posts\/691\/revisions\/1188"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/buhave.com\/courses\/wp-json\/wp\/v2\/media\/692"}],"wp:attachment":[{"href":"https:\/\/buhave.com\/courses\/wp-json\/wp\/v2\/media?parent=691"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/buhave.com\/courses\/wp-json\/wp\/v2\/categories?post=691"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/buhave.com\/courses\/wp-json\/wp\/v2\/tags?post=691"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}