Core OOP Principles:
Introduction to OOP
- Object-Oriented Programming (OOP) is a paradigm that uses "objects" to design and structure software. Each object represents a real-world entity with attributes (properties) and behaviors (methods). The goal is to make code modular, reusable, and easier to maintain.
Encapsulation
- Bundling of data (attributes) and methods (functions) that operate on the data into a single unit (class).
- Ensures data hiding and controlled access using access modifiers.
Abstraction:
- Hides implementation details from the user, exposing only the functionality.
Achieved using abstract classes or interfaces.
Inheritance:
- Mechanism to acquire properties and behaviors of a parent class in a child class.
Promotes code reusability.
Polymorphism:
- Ability of a single interface to represent different forms.
- Achieved using method overloading (compile-time) and method overriding (runtime).