<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Hamilpuryashica on Medium]]></title>
        <description><![CDATA[Stories by Hamilpuryashica on Medium]]></description>
        <link>https://medium.com/@hamilpuryashica?source=rss-4611701c5c2a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*VmZPrSP_puZSQUH4</url>
            <title>Stories by Hamilpuryashica on Medium</title>
            <link>https://medium.com/@hamilpuryashica?source=rss-4611701c5c2a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 23 May 2026 15:33:13 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@hamilpuryashica/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com" rel="hub"/>
        <item>
            <title><![CDATA[Inheritance in Object-Oriented Programming (OOP)]]></title>
            <link>https://medium.com/@hamilpuryashica/inheritance-in-object-oriented-programming-oop-5f0f0e60339d?source=rss-4611701c5c2a------2</link>
            <guid isPermaLink="false">https://medium.com/p/5f0f0e60339d</guid>
            <category><![CDATA[inheritance]]></category>
            <dc:creator><![CDATA[Hamilpuryashica]]></dc:creator>
            <pubDate>Sat, 27 Dec 2025 08:54:39 GMT</pubDate>
            <atom:updated>2025-12-27T08:54:39.020Z</atom:updated>
            <content:encoded><![CDATA[<p>Inheritance in Object-Oriented Programming (OOP)</p><p>Inheritance is one of the most important concepts in Object-Oriented Programming (OOP). It allows one class to reuse the properties and behaviors of another class. This helps in writing clean, reusable, and easy-to-maintain code.</p><p>What is Inheritance?</p><p>Inheritance is a mechanism where one class acquires the properties (variables) and behaviors (methods) of another class.</p><p>The class that provides features is called the Base Class (Parent Class)</p><p>The class that receives features is called the Subclass (Child Class)</p><p>👉 Inheritance represents an “IS-A” relationship</p><p>Example:</p><p>A Car is a Vehicle</p><p>Base Class (Parent Class)</p><p>The base class is the class whose properties and methods are inherited by another class.</p><p>Example:</p><p>Copy code</p><p>Java</p><p>class Vehicle {</p><p>int speed = 60;</p><p>void showSpeed() {</p><p>System.out.println(“Speed: “ + speed);</p><p>}</p><p>}</p><p>Here, Vehicle is the base class.</p><p>Subclass (Child Class)</p><p>The subclass is the class that inherits from the base class using keywords like:</p><p>extends (Java)</p><p>: (Python)</p><p>Example:</p><p>Copy code</p><p>Java</p><p>class Car extends Vehicle {</p><p>void showType() {</p><p>System.out.println(“This is a car”);</p><p>}</p><p>}</p><p>Here, Car is the subclass that inherits from Vehicle.</p><p>Object Creation in Inheritance</p><p>An object of the subclass can access members of:</p><p>Its own class</p><p>The base class</p><p>Copy code</p><p>Java</p><p>public class Main {</p><p>public static void main(String[] args) {</p><p>Car c = new Car();</p><p>c.showSpeed(); // from base class</p><p>c.showType(); // from subclass</p><p>}</p><p>}</p><p>Member Access Rules in Inheritance</p><p>Access to class members depends on access modifiers.</p><p>Common Access Modifiers:</p><p>public</p><p>protected</p><p>default</p><p>private</p><p>Access Rules Table (Java)</p><p>Access Modifier</p><p>Same Class</p><p>Same Package</p><p>Subclass</p><p>Outside Package</p><p>public</p><p>✔</p><p>✔</p><p>✔</p><p>✔</p><p>protected</p><p>✔</p><p>✔</p><p>✔</p><p>❌</p><p>default</p><p>✔</p><p>✔</p><p>❌</p><p>❌</p><p>private</p><p>✔</p><p>❌</p><p>❌</p><p>❌</p><p>Example with Access Modifiers:</p><p>Copy code</p><p>Java</p><p>class Parent {</p><p>public int a = 10;</p><p>protected int b = 20;</p><p>int c = 30; // default</p><p>private int d = 40;</p><p>}</p><p>Copy code</p><p>Java</p><p>class Child extends Parent {</p><p>void display() {</p><p>System.out.println(a); // allowed</p><p>System.out.println(b); // allowed</p><p>System.out.println(c); // allowed (same package)</p><p>// System.out.println(d); // NOT allowed</p><p>}</p><p>}</p><p>❌ Private members cannot be inherited.</p><p>Why Use Inheritance?</p><p>Inheritance provides many benefits:</p><p>✔ Code reusability</p><p>✔ Less duplication</p><p>✔ Easy maintenance</p><p>✔ Supports polymorphism</p><p>✔ Improves program structure</p><p>Real-World Example of Inheritance</p><p>Base Class: Employee</p><p>Subclass: Manager</p><p>A Manager is an Employee, but has extra responsibilities.</p><p>Conclusion</p><p>Inheritance helps classes share common behavior while allowing specialization. Understanding base classes, subclasses, and member access rules is essential for mastering OOP concepts and building real-world applications.vInheritance in Object-Oriented Programming (OOP)</p><p>Inheritance is one of the most important concepts in Object-Oriented Programming (OOP). It allows one class to reuse the properties and behaviors of another class. This helps in writing clean, reusable, and easy-to-maintain code.</p><p>What is Inheritance?</p><p>Inheritance is a mechanism where one class acquires the properties (variables) and behaviors (methods) of another class.</p><p>The class that provides features is called the Base Class (Parent Class)</p><p>The class that receives features is called the Subclass (Child Class)</p><p>👉 Inheritance represents an “IS-A” relationship</p><p>Example:</p><p>A Car is a Vehicle</p><p>Base Class (Parent Class)</p><p>The base class is the class whose properties and methods are inherited by another class.</p><p>Example:</p><p>Copy code</p><p>Java</p><p>class Vehicle {</p><p>int speed = 60;</p><p>void showSpeed() {</p><p>System.out.println(“Speed: “ + speed);</p><p>}</p><p>}</p><p>Here, Vehicle is the base class.</p><p>Subclass (Child Class)</p><p>The subclass is the class that inherits from the base class using keywords like:</p><p>extends (Java)</p><p>: (Python)</p><p>Example:</p><p>Copy code</p><p>Java</p><p>class Car extends Vehicle {</p><p>void showType() {</p><p>System.out.println(“This is a car”);</p><p>}</p><p>}</p><p>Here, Car is the subclass that inherits from Vehicle.</p><p>Object Creation in Inheritance</p><p>An object of the subclass can access members of:</p><p>Its own class</p><p>The base class</p><p>Copy code</p><p>Java</p><p>public class Main {</p><p>public static void main(String[] args) {</p><p>Car c = new Car();</p><p>c.showSpeed(); // from base class</p><p>c.showType(); // from subclass</p><p>}</p><p>}</p><p>Member Access Rules in Inheritance</p><p>Access to class members depends on access modifiers.</p><p>Common Access Modifiers:</p><p>public</p><p>protected</p><p>default</p><p>private</p><p>Access Rules Table (Java)</p><p>Access Modifier</p><p>Same Class</p><p>Same Package</p><p>Subclass</p><p>Outside Package</p><p>public</p><p>✔</p><p>✔</p><p>✔</p><p>✔</p><p>protected</p><p>✔</p><p>✔</p><p>✔</p><p>❌</p><p>default</p><p>✔</p><p>✔</p><p>❌</p><p>❌</p><p>private</p><p>✔</p><p>❌</p><p>❌</p><p>❌</p><p>Example with Access Modifiers:</p><p>Copy code</p><p>Java</p><p>class Parent {</p><p>public int a = 10;</p><p>protected int b = 20;</p><p>int c = 30; // default</p><p>private int d = 40;</p><p>}</p><p>Copy code</p><p>Java</p><p>class Child extends Parent {</p><p>void display() {</p><p>System.out.println(a); // allowed</p><p>System.out.println(b); // allowed</p><p>System.out.println(c); // allowed (same package)</p><p>// System.out.println(d); // NOT allowed</p><p>}</p><p>}</p><p>❌ Private members cannot be inherited.</p><p>Why Use Inheritance?</p><p>Inheritance provides many benefits:</p><p>✔ Code reusability</p><p>✔ Less duplication</p><p>✔ Easy maintenance</p><p>✔ Supports polymorphism</p><p>✔ Improves program structure</p><p>Real-World Example of Inheritance</p><p>Base Class: Employee</p><p>Subclass: Manager</p><p>A Manager is an Employee, but has extra responsibilities.</p><p>ConInheritance in Object-Oriented Programming (OOP)</p><p>Inheritance is one of the most important concepts in Object-Oriented Programming (OOP). It allows one class to reuse the properties and behaviors of another class. This helps in writing clean, reusable, and easy-to-maintain code.</p><p>What is Inheritance?</p><p>Inheritance is a mechanism where one class acquires the properties (variables) and behaviors (methods) of another class.</p><p>The class that provides features is called the Base Class (Parent Class)</p><p>The class that receives features is called the Subclass (Child Class)</p><p>👉 Inheritance represents an “IS-A” relationship</p><p>Example:</p><p>A Car is a Vehicle</p><p>Base Class (Parent Class)</p><p>The base class is the class whose properties and methods are inherited by another class.</p><p>Example:</p><p>Copy code</p><p>Java</p><p>class Vehicle {</p><p>int speed = 60;</p><p>void showSpeed() {</p><p>System.out.println(“Speed: “ + speed);</p><p>}</p><p>}</p><p>Here, Vehicle is the base class.</p><p>Subclass (Child Class)</p><p>The subclass is the class that inherits from the base class using keywords like:</p><p>extends (Java)</p><p>: (Python)</p><p>Example:</p><p>Copy code</p><p>Java</p><p>class Car extends Vehicle {</p><p>void showType() {</p><p>System.out.println(“This is a car”);</p><p>}</p><p>}</p><p>Here, Car is the subclass that inherits from Vehicle.</p><p>Object Creation in Inheritance</p><p>An object of the subclass can access members of:</p><p>Its own class</p><p>The base class</p><p>Copy code</p><p>Java</p><p>public class Main {</p><p>public static void main(String[] args) {</p><p>Car c = new Car();</p><p>c.showSpeed(); // from base class</p><p>c.showType(); // from subclass</p><p>}</p><p>}</p><p>Member Access Rules in Inheritance</p><p>Access to class members depends on access modifiers.</p><p>Common Access Modifiers:</p><p>public</p><p>protected</p><p>default</p><p>private</p><p>Access Rules Table (Java)</p><p>Access Modifier</p><p>Same Class</p><p>Same Package</p><p>Subclass</p><p>Outside Package</p><p>public</p><p>✔</p><p>✔</p><p>✔</p><p>✔</p><p>protected</p><p>✔</p><p>✔</p><p>✔</p><p>❌</p><p>default</p><p>✔</p><p>✔</p><p>❌</p><p>❌</p><p>private</p><p>✔</p><p>❌</p><p>❌</p><p>❌</p><p>Example with Access Modifiers:</p><p>Copy code</p><p>Java</p><p>class Parent {</p><p>public int a = 10;</p><p>protected int b = 20;</p><p>int c = 30; // default</p><p>private int d = 40;</p><p>}</p><p>Copy code</p><p>Java</p><p>class Child extends Parent {</p><p>void display() {</p><p>System.out.println(a); // allowed</p><p>System.out.println(b); // allowed</p><p>System.out.println(c); // allowed (same package)</p><p>// System.out.println(d); // NOT allowed</p><p>}</p><p>}</p><p>❌ Private members cannot be inherited.</p><p>Why Use Inheritance?</p><p>Inheritance provides many benefits:</p><p>✔ Code reusability</p><p>✔ Less duplication</p><p>✔ Easy maintenance</p><p>✔ Supports polymorphism</p><p>✔ Improves program structure</p><p>Real-World Example of Inheritance</p><p>Base Class: Employee</p><p>Subclass: Manager</p><p>A Manager is an Employee, but has extra responsibilities.</p><p>Conclusion</p><p>Inheritance helps classes share common behavior while allowing specialization. Understanding base classes, subclasses, and member access rules is essential for mastering OOP concepts and building real-world applications.clusion</p><p>Inheritance helps classes share common behavior while allowing specialization. Understanding base classes, subclasses, and member access rules is essential for mastering OOP concepts and building real-world applications.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5f0f0e60339d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>