Site icon Gyanodhan

Unit 9: Object Oriented Programming

Review of Fundamentals of Procedural Programming, Class and Objects, Data Abstraction, Information Hiding & Encapsulation, Constructors, destructors, and object creation, Name space and references , Class Methods , Methods Overloading , Inheritance , Polymorphism , Abstract Classes, Abstract Methods , Exceptions , Exception Handling.

🔄 Review of Fundamentals of Procedural Programming (प्रोसीजरल प्रोग्रामिंग के मूल)


🏷️ Class and Objects (क्लास और ऑब्जेक्ट्स)


🛡️ Data Abstraction, Information Hiding & Encapsulation


⚙️ Constructors, Destructors, and Object Creation


🏷️ Namespace and References


🧩 Class Methods and Method Overloading


🌳 Inheritance (विरासत)


🔄 Polymorphism (बहुरूपता)


🏛️ Abstract Classes and Abstract Methods


Exceptions and Exception Handling


📚 संक्षेप सारांश:

कॉन्सेप्टविवरण
Procedural Programmingफंक्शन पर आधारित प्रोग्रामिंग
Class & Objectsडेटा और फंक्शन का ब्लूप्रिंट और उसका उदाहरण
Data Abstractionजरूरी जानकारी दिखाना, बाकी छुपाना
Encapsulationडेटा और मेथड्स को क्लास में बांधना
Constructor & Destructorऑब्जेक्ट की शुरुआत और अंत में स्वचालित कार्य
Namespace & Referencesनामों का संगठन और संदर्भ
Method Overloadingएक नाम के कई मेथड्स
Inheritanceक्लास से गुण और व्यवहार लेना
Polymorphismएक interface के कई रूप
Abstract Classes/Methodsबेस क्लास और बिना implementation वाले मेथड्स
Exceptionsरनटाइम errors और उनका हैंडलिंग

====================*****====================

🏛️ 1. Abstract Class (एब्सट्रैक्ट क्लास)

👉 परिभाषा:

Abstract class एक ऐसी class होती है:

✅ उपयोग कब करें?

जब आप चाहते हैं कि कुछ common structure तो सभी subclasses में हो, लेकिन हर subclass उसे अपने तरीके से implement करे।

📌 विशेषताएँ:


📍 उदाहरण (C++ style):

// Abstract Class
class Shape {
public:
    virtual void draw() = 0;  // Abstract Method
};

// Subclass
class Circle : public Shape {
public:
    void draw() override {
        cout << "Circle draw हो रहा है" << endl;
    }
};

🧩 2. Abstract Method (एब्सट्रैक्ट मेथड)

👉 परिभाषा:

Abstract Method वह होता है जो सिर्फ declared होता है, लेकिन उसका कोई body/implementation नहीं होता

उदाहरण:

virtual void draw() = 0;

यह एक pure virtual function है → यानी abstract method।


⚙️ Java में Abstract Example:

abstract class Animal {
    abstract void sound();  // abstract method
}

class Dog extends Animal {
    void sound() {
        System.out.println("Bark");
    }
}

🔄 Abstract Class बनाम Interface (Java/C# में):

AspectAbstract ClassInterface
MethodsAbstract + Concreteकेवल Abstract (Java 8+ में default भी)
Inheritanceएक ही abstract classकई interfaces implement कर सकते हैं
Constructorहोता हैनहीं होता

📚 सारांश (Summary):

टॉपिकविवरण
Abstract Classऐसा base class जिसका object नहीं बनता
Abstract Methodऐसा method जिसका body नहीं होता
उद्देश्यStructure देना, implementation subclasses में छोड़ना
Exit mobile version