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)

Every Android app. Every bank ATM. Every Zomato backend. Every Infosys enterprise system. They all run Java.

Java is 30 years old and still the #1 language for backend jobs in India. Today you write your first real Java program — an ATM simulation with real logic: balance checks, deposits, withdrawals.

☕ Core Java Concepts (5–20 min)

💡 Mental Model

Variable — a labelled box storing a value.
Method — a named set of instructions.
if/else — a decision (if balance enough, allow withdrawal).
for loop — repeat N times (process 100 transactions).

💻 Live Coding — ATM Simulation (20–40 min)

public class ATM {
    private String owner;
    private double balance;

    public ATM(String owner, double initialBalance) {
        this.owner   = owner;
        this.balance = initialBalance;
    }

    public void deposit(double amount) {
        if (amount <= 0) { System.out.println("Invalid amount"); return; }
        balance += amount;
        System.out.println("Deposited ₹" + amount + ". Balance: ₹" + balance);
    }

    public void withdraw(double amount) {
        if (amount > balance) {
            System.out.println("Insufficient funds!");
        } else {
            balance -= amount;
            System.out.println("Withdrawn ₹" + amount + ". Remaining: ₹" + balance);
        }
    }

    public static void main(String[] args) {
        ATM atm = new ATM("Priya", 10000);
        atm.deposit(5000);
        atm.withdraw(3000);
        atm.withdraw(20000);  // Insufficient funds!
    }
}

🔄 Processing Multiple Transactions with for-each

double[] transactions = {500, -200, 1000, -50, -800};
double balance = 5000;
for (double t : transactions) {
    if (t > 0) balance += t;
    else       balance -= Math.abs(t);
    System.out.println("Balance: ₹" + balance);
}
🎯 You Code It (40–55 min)
  1. Create a GradeCalculator class with method getGrade(int marks)
  2. Logic: marks≥90="A", ≥75="B", ≥60="C", ≥50="D", else="F"
  3. Add method processClass(int[] marks) — print grade for each student
  4. Add method getClassAverage(int[] marks) — returns average as double
  5. Test with: int[] marks = {92, 45, 78, 63, 88, 31, 95}
  6. Show the instructor: Expected output shows all grades + class average

📄 Day 3 Cheat Sheet — Java Fundamentals

Primitive Types

int n = 42;Whole number
double d = 3.14;Decimal
boolean b = true;True/false
char c = 'A';Single char
String s = "hi";Text (Object)
long l = 99999L;Big whole number

String Methods

s.length()Character count
s.toUpperCase()All caps
s.contains("x")Check substring
s.replace("a","b")Replace
s.trim()Remove spaces
s.split(",")Split to array

Control Flow

if (x>0) {}Condition
else if (x==0) {}Another branch
for (int i=0;i<n;i++) {}Count loop
for (T x : list) {}For-each
while (cond) {}While loop
return value;Exit method

Useful Utils

Integer.parseInt("5")String->int
String.valueOf(42)int->String
Math.max(a,b)Larger value
Math.abs(n)Absolute value
Math.random()0.0 to 1.0
System.out.printf("%.2f",x)Formatted print