Q11: What are the Four Pillars of Object-Oriented Programming (OOP)?

  1. Encapsulation: Hiding state behind private fields, exposing access via controlled public methods.
  2. Abstraction: Hiding internal implementation complexity behind simple abstract interfaces or classes.
  3. Inheritance: Deriving new classes from parent classes to promote code reuse (extends).
  4. Polymorphism: Allowing objects to take multiple forms (Method Overloading and Method Overriding).
Key Takeaways
  • Encapsulation protects data integrity.
  • Abstraction simplifies user interaction contracts.
  • Inheritance models 'IS-A' hierarchies.
  • Polymorphism provides dynamic runtime dispatch.
Knowledge Check

Hiding implementation complexity and exposing only essential functional contracts is known as what?