Course home
OOP THROUGH JAVA UNIT II · UI24PC320CS JDK 21
2UNIT

12 classes · 3 labs · 14 PYQs

Classes deepened, exceptions & threads.

Access modifiers · encapsulation, the fourth pillar · Singleton & nested classes · interfaces deepened & packages · the exception hierarchy, try/catch/finally & your own exceptions · threads, the lifecycle, synchronization & deadlock. A canteen card, a campus Wi-Fi login, a food-ordering app's crash logs, and two students racing for the last movie ticket.

PART F · C13–C14 · MODIFIERS + ENCAPSULATION PART G · C15–C16 · SINGLETON + NESTED + INTERFACE + PACKAGE LAB 3 · PACKAGES PART H · C17–C20 · EXCEPTIONS LAB 4 · EXCEPTION HANDLING PART I · C21–C24 · THREADS LAB 5 · THREAD SYNC
⚡ ADVANCED CRASH COURSE The whole of Unit 2 as a fast-track sprint — 15 modules, ≈ 9 hours across 4 sittings, every exam question answered in place. Fast-track revision path: classes & interfaces, exception handling and multithreaded programming, building one Eclipse project from an empty folder to a working multithreaded program — every line typed, run, and shown with its real console output. START THE SPRINT →

THE EXACT SESSION ORDER — FOLLOW IT TOP TO BOTTOM

Every session, in the order we meet it.

Strict four-classes-per-lab, exactly as the knowledge doc plans it — LAB 3 lands after Class 16, LAB 4 after Class 20, LAB 5 after Class 24. Sessions unlock as they are authored; everything below is dimmed until its page goes live.

PART F · WHO CAN SEE WHAT — MODIFIERS, THEN ENCAPSULATION
C13 Access modifiers — private · default · protected · public

Who can see what across a Java codebase — all four levels, the full visibility matrix, and a CampusEventApp walkthrough. PYQs P2·Q11a and P1·Q12b solved in place.

PART F● LIVE
C14 Encapsulation — Unit 1's silent fourth pillar

A CanteenCard whose balance can never go negative — getters/setters with validation, the immutable-class recipe, and four PYQs landing here (P1·Q5 · P1·Q11a · P1·Q11b · P1·Q16a).

PART F● LIVE
PART G · ONE-OF-A-KIND CLASSES & REAL PROJECT LAYOUT
C15 Abstract deepened · Singleton · nested classes

The campus Wi-Fi enforces one active login per roll number — that's why Singleton exists. Private constructor + getInstance(), then the four kinds of nested class. PYQs P2·Q12a (abstract Reservation) and P1·Q4 (private constructor).

PART G● LIVE
C16 Interface deepened · packages

Java 8 default & static methods, marker interfaces, the VasaviLibrary PYQ (P2·Q16b) — then com.college.attendance built both in Eclipse and by hand with javac -d.

PART G● LIVE
L3LAB LAB 3 · Packages

Syllabus Lab 3 — a two-package campus-attendance app: AttendanceCalculator in com.college.attendance, driven cross-package by Main, compiled with javac -d.

AFTER C16● LIVE
PART H · WHEN THINGS BREAK — EXCEPTIONS, END TO END
C17 Exceptions — what, hierarchy, checked vs unchecked

A campus food-ordering app's real crash logs become the source of every example — ThrowableError / ExceptionRuntimeException, and PYQ P2·Q4 on checked vs unchecked.

PART H○ SOON
C18 try/catch/finally · multi-catch · throw vs throws

A movie-ticket counter holds a seat that must be released on both the success and failure paths — that's what finally is for. PYQ P1·Q3 on multiple catch blocks.

PART H○ SOON
C19 Propagation · stack traces · user-defined exceptions

How an error travels up the call stack, how to read the trace the JVM prints, and your first custom exception — OutOfStockException in the food-ordering cart.

PART H○ SOON
C20 Exception PYQs · chaining · best practices

Three exam questions answered in one class — InvalidAgeException (P2·Q12b), the banking multi-catch (P1·Q16b), the insurance hierarchy (P1·Q12a) — then chaining, best practices, and the cheat sheet.

PART H○ SOON
L4LAB LAB 4 · Exception handling

Syllabus Lab 4 — InvalidAgeException with a re-prompt loop, then the BankAccount[] multi-catch/throws/finally build. Both PYQs' real-world forms.

AFTER C20● LIVE
PART I · TWO THINGS AT ONCE — THREADS TO DEADLOCK
C21 Threads — what, why, creating them

Process vs thread, why apps need both a live map and an updating order status — then the two ways to make one: extends Thread vs implements Runnable, and which is generally better.

PART I○ SOON
C22 Thread lifecycle · priority · control

start() vs run() — the classic mistake — then the five states between NEW and TERMINATED, sleep()/join(), priority as a hint not a guarantee, and interruption.

PART I○ SOON
C23 Race conditions · synchronized · volatile

Two students book the last seat at the same instant — the MovieTicketCounter race, unsynchronized vs synchronized bookTicket() side by side. PYQ P2·Q3 on why synchronization matters. Feeds Lab 5 directly.

PART I○ SOON
C24 Inter-thread communication · deadlock · Unit-2 close

wait()/notify(), producer–consumer, the classic two-lock deadlock and how to prevent it — then the honest four-pillar teach-back, now that encapsulation is truly in hand.

PART I○ SOON
L5LAB LAB 5 · Thread synchronization

Syllabus Lab 5 — MovieTicketCounterUnsafe vs MovieTicketCounterSafe: Diya's and Rohit's booking threads race for one ticket, the overbooking bug appears on screen, then synchronized provably fixes it.

AFTER C24● LIVE

14 verified past-paper questions live inside these sessions.

Every PYQ is solved on a ruled notebook sheet, point by point — from P2·Q11a (access specifiers) at Class 13 to P2·Q3 (thread synchronization) at Class 23 — and each is elaborated beyond its marks weightage so no re-skin can surprise you. Two of them land twice: their exam form in class, their real-world form again in Lab 4.