0–5 min
Real Hook
5–20 min
Core Concept
20–40 min
Live Coding
40–55 min
You Code It
55–60 min
Cheat Sheet
🔥 Real-World Hook (0–5 min)

Why does your phone update Instagram without reinstalling the whole OS? Why can a Toyota mechanic understand a BMW engine?

Object-Oriented Design. Everything is built from reusable blueprints (classes). Change one blueprint — all objects update. This is how Netflix, Uber, and Amazon build software that lasts decades.

🌍 The 4 Pillars (5–20 min)

💡 Analogies

Encapsulation — A capsule hides the chemical inside. You swallow it (call the method), not mix chemicals yourself.
Inheritance — A Manager IS an Employee. Child class gets everything from parent — no duplication.
Polymorphism — "Open" means different things: open a door, open a file. Same method name, different behaviour.
Abstraction — You drive a car without knowing the engine. Abstract class hides complexity.

💻 Live Coding — Employee Hierarchy (20–40 min)

public class Employee {
    protected String name;
    protected double salary;

    public Employee(String name, double salary) {
        this.name = name; this.salary = salary;
    }

    public void work() {
        System.out.println(name + " is working");
    }
}

public class Manager extends Employee {
    private int teamSize;

    public Manager(String name, double salary, int teamSize) {
        super(name, salary);
        this.teamSize = teamSize;
    }

    @Override
    public void work() {   // Polymorphism
        System.out.println(name + " is managing a team of " + teamSize);
    }
}

// Usage
Employee emp = new Employee("Priya", 50000);
Manager  mgr = new Manager("Ravi", 90000, 8);
emp.work();  // "Priya is working"
mgr.work();  // "Ravi is managing a team of 8"

🔗 Interface — A Contract Every Class Must Honour

interface Payable {
    double calculatePay();
}

class FullTimeEmployee implements Payable {
    public double calculatePay() { return 50000; }
}

class Contractor implements Payable {
    private int hours;
    public double calculatePay() { return hours * 500; }
}
🎯 You Code It (40–55 min)
  1. Create a BankAccount class: fields accountNo, balance; methods deposit(), withdraw(), getBalance()
  2. Create SavingsAccount extends BankAccount — override withdraw() to prevent balance going below ₹500
  3. Create LoanAccount extends BankAccount — add field interestRate, method calculateInterest(int months)
  4. In main(): deposit ₹10,000 then try withdrawing ₹9,800 from SavingsAccount
  5. Goal: SavingsAccount prints "Cannot withdraw — minimum balance required"

📄 Day 4 Cheat Sheet — OOP

Class & Object

class Car { }Blueprint
Car c = new Car()Create object
private int speedHidden field
public int getSpeed()Getter
this.speed = speedOwn field

Inheritance

class Dog extends AnimalInherit
super(name)Call parent constructor
super.speak()Call parent method
@OverrideReplace parent method
instanceofCheck type

Interface

interface Flyable { }Define contract
class Bird implements FlyableImplement
default void method()Optional override
implements A, BMultiple OK
extends only ONE classSingle inheritance

Access Modifiers

publicAnyone can access
privateOnly this class
protectedThis + subclasses
abstractMust be subclassed
finalCannot override
staticBelongs to class