2.1 Foundational Principles of Object Orientation
Core OOP Principles:
- Class: A blueprint, template, or prototype defining the attributes (state) and operations (behavior) that objects of that type possess.
- Object: A concrete runtime instance of a class with an identity, a state (attribute values), and behavior.
- Encapsulation & Data Hiding: Bundling data attributes and operations that manipulate them within a single unit and restricting direct external access via access modifiers (
private,protected,public). - Abstraction: Exposing only essential characteristics of an entity while hiding unnecessary implementation complexity.
- Inheritance (Generalization): Mechanism by which a subclass inherits attributes and operations from a superclass (IS-A relationship), promoting code reuse.
- Polymorphism: Ability of a single interface to take multiple forms (Compile-time Method Overloading vs Runtime Method Overriding).
- Interface: A pure contract defining abstract method signatures without implementation details that implementing classes must satisfy.