PrepZone Logo
PrepZone

Four OOP Pillars Applied to Design

How encapsulation, abstraction, inheritance, and polymorphism show up in real class diagrams.

Why this matters

  • Interviewers expect pillars as design decisions, not textbook definitions.
  • Each pillar answers a different change scenario — encapsulation vs polymorphism.
  • CampusOS modules reuse the same pillar vocabulary across parking, booking, and feeds.
  • Links to Core Java OOP — this article applies those ideas to class diagrams.
EncapsulationHide the data, expose behaviour
AbstractionPublish intent, hide mechanics
InheritanceReuse a parent contract
PolymorphismOne call, many outcomes
Encapsulation and abstraction decide what the outside world can see. Inheritance and polymorphism decide how types relate and which code actually runs.

Overview

How encapsulation, abstraction, inheritance, and polymorphism show up in real class diagrams. Study each section below in order — every list is interview-ready reference material.

Encapsulation in CampusOS

Points to cover

  • Definition — what Encapsulation in CampusOS means in one clear sentence
  • When to use — the force or smell that triggers this concept
  • CampusOS example — where this appears in parking, booking, or library modules
  • How to explain — pointwise bullets you can say aloud in an interview
  • Common mistake — what weak candidates do instead
  • Refactor move — one concrete change that improves the design

Abstraction boundaries

Points to cover

  • Definition — what Abstraction boundaries means in one clear sentence
  • When to use — the force or smell that triggers this concept
  • CampusOS example — where this appears in parking, booking, or library modules
  • How to explain — pointwise bullets you can say aloud in an interview
  • Common mistake — what weak candidates do instead
  • Refactor move — one concrete change that improves the design

When inheritance helps

Points to cover

  • Definition — what When inheritance helps means in one clear sentence
  • When to use — the force or smell that triggers this concept
  • CampusOS example — where this appears in parking, booking, or library modules
  • How to explain — pointwise bullets you can say aloud in an interview
  • Common mistake — what weak candidates do instead
  • Refactor move — one concrete change that improves the design

Polymorphism over switches

Points to cover

  • Definition — what Polymorphism over switches means in one clear sentence
  • When to use — the force or smell that triggers this concept
  • CampusOS example — where this appears in parking, booking, or library modules
  • How to explain — pointwise bullets you can say aloud in an interview
  • Common mistake — what weak candidates do instead
  • Refactor move — one concrete change that improves the design
Java
// CampusOS — apply "Encapsulation in CampusOS" on paper first, then in code
public final class OopPillarsInPracticeExample {
    // 1. Name entities from the problem statement
    // 2. Draw relationships before writing methods
    // 3. Introduce patterns only when a force appears
}

Quick recall

Everything you need if you only revisit this box.

  1. Encapsulation in CampusOS — review this slice before mock interviews.
  2. Abstraction boundaries — review this slice before mock interviews.
  3. When inheritance helps — review this slice before mock interviews.
  4. Polymorphism over switches — review this slice before mock interviews.

Test yourself

Answer these before moving on — recall is what makes it stick.