What is Object Oriented programming ?
Object-Oriented Programming (OOP) is a programming paradigm based on the concept of objects that contain data (fields) and behavior (methods). It focuses on designing software that closely represents real-world entities. It is used to:
- Improves code reusability
- Enhances maintainability and scalability
- Makes programs easier to understand and manage
- Closely models real-world entities
Characteristics of OOP:
| Characteristic | Description |
|---|---|
| Class | Blueprint for objects |
| Object | Instance of a class |
| Encapsulation | Data hiding and protection |
| Abstraction | Hiding implementation details |
| Inheritance | Acquiring properties from another class |
| Polymorphism | One interface, multiple behaviors |
Class:
A class is a user-defined blueprint or template used to create objects. It defines the data (attributes) and behavior (methods) that objects of that class will have.
Think of a class as a design or blueprint, and an object as the actual thing built from that blueprint.
Object
An object is an instance of a class. It is a real entity created from the blueprint (class) and occupies memory during program execution.
Class = Blueprint/Template
Object = Actual thing created from that blueprint
Inheritance
Inheritance is an OOP mechanism that allows one class to acquire the properties (fields) and behaviors (methods) of another class.
It promotes code reusability because common features are written once in a parent class and reused by child classes.
Top comments (0)