Object-Oriented Programming (OOP)
A programming paradigm based on the concept of 'objects', which can contain data and code.
Object-Oriented Programming (OOP) is a paradigm that structures code around 'objects'—self-contained units containing both data (attributes) and code (methods).
Four pillars of OOP:
1. Encapsulation: Bundling data and methods, hiding internal state
2. Abstraction: Exposing only essential features, hiding complexity
3. Inheritance: Classes inherit properties/methods from parent classes
4. Polymorphism: Same interface, different implementations
Key concepts: Class (blueprint), Object (instance), Constructor, Method. OOP promotes reusability and maintainability.
graph LR
Center["Object-Oriented Programming (OOP)"]:::main
Rel_functional_programming["functional-programming"]:::related -.-> Center
click Rel_functional_programming "/terms/functional-programming"
Rel_java["java"]:::related -.-> Center
click Rel_java "/terms/java"
Rel_stored_program_concept["stored-program-concept"]:::related -.-> Center
click Rel_stored_program_concept "/terms/stored-program-concept"
classDef main fill:#7c3aed,stroke:#8b5cf6,stroke-width:2px,color:white,font-weight:bold,rx:5,ry:5;
classDef pre fill:#0f172a,stroke:#3b82f6,color:#94a3b8,rx:5,ry:5;
classDef child fill:#0f172a,stroke:#10b981,color:#94a3b8,rx:5,ry:5;
classDef related fill:#0f172a,stroke:#8b5cf6,stroke-dasharray: 5 5,color:#94a3b8,rx:5,ry:5;
linkStyle default stroke:#4b5563,stroke-width:2px;
🧠 Knowledge Check
🧒 Explain Like I'm 5
Think of LEGO instructions. A [class](/en/terms/class) is like the instructions for building a house. Each house you build following those instructions is an [object](/en/terms/object). Different houses can share parts (inheritance) but look different (polymorphism)!