Chapter 6: Object-Oriented Concepts 💡
This cheat sheet covers the basic principles of OOP for Chapter 6 of the GSEB Std 12 Computer Studies syllabus.
🎯 Key Concepts
- OOP: A programming paradigm that models real-world entities into classes and objects.
- Class: A logical blueprint for creating objects.
- Object: A physical instance of a class. Has State (attributes) and Behavior (methods).
🏛️ The Four Pillars of OOP (Detailed)
1. Abstraction (Essential Features)
Representing only the essential features without including background details.
- Goal: To simplify the user's view of a complex system.
- Example: Using a microwave without knowing its internal circuitry.
2. Encapsulation (Data Hiding)
Wrapping data and methods together into a single unit (Class) to ensure security.
- Goal: To prevent external code from directly modifying data.
- Example: Making attributes private and using methods to access them.
3. Inheritance (Reusability)
One class acquiring properties from another.
- Generalization: Creating a general class (e.g.,
Vehicle) from specific ones (Car,Bus). - Specialization: Creating specific classes from a general one.
- Relationship: "is-a" relationship (e.g., Car is-a Vehicle).
4. Polymorphism (Many Forms)
The ability of a function or method to behave differently based on the data it is processing.
- Example: A single
draw()method drawing different shapes like Circle, Square.
⚙️ Relationships between Classes
1. Aggregation (Weak Has-a)
Represents a relationship where one class contains another, but they can exist independently.
- Symbol: Empty Diamond (◇)
- Example: A Car and its Radio. If the car is destroyed, the radio can still exist.
2. Composition (Strong Has-a)
A strong form of aggregation where the contained object cannot exist without the container.
- Symbol: Filled Diamond (◆)
- Example: A Person and their Heart. If the person dies, the heart cannot exist on its own.
💡 Board Focus: High-Weightage Points 👔
- MCQ Alert: Generalization is the "is-a" relationship.
- MCQ Alert: Aggregation and Composition are both "has-a" relationships.
- MCQ Alert: Abstraction provides the "outside" view, while Encapsulation provides the "inside" view.
- MCQ Alert: Class is the blueprint; Object is the real entity.
- MCQ Alert: OOP promotes Software Reusability through Inheritance.
Board Exam Secret
GSEB frequently asks about the Diamond symbol. Remember: Empty Diamond = Aggregation, Filled Diamond = Composition.