Skip to content

Topic 2: OOP & Class Design Internals

Mastering object-oriented programming principles and understanding how Java implements them internally.


Topic Structure

Document Purpose Status
Topic Note Part 1 Classes, Objects & Encapsulation Complete
Topic Note Part 2 Inheritance & Method Overriding Complete
Topic Note Part 3 Strings & StringBuilder Complete
Topic Note Part 4 Composition Complete
Topic Note Part 5 Encapsulation (Advanced) Complete
Topic Note Part 6 Polymorphism Complete
OOP Challenges Inheritance & OOP Master Challenges Complete
Book Reading Effective Java insights Complete
Summary Combined final understanding Complete

Topic Notes Overview

Part 1: Classes, Objects & Encapsulation

Covers foundational OOP concepts including class anatomy, access modifiers, getters/setters, constructors (default, parameterized, chaining), references vs objects, static vs instance members, POJOs, and Java Records.

Part 2: Inheritance & Method Overriding

Covers the extends keyword, superclass/subclass relationships, the super keyword, constructor chaining across classes, method overriding with @Override, java.lang.Object as the root class, and the differences between overloading vs overriding.

Part 3: Strings & StringBuilder

Covers Text Blocks (JDK 15+), escape sequences, printf formatting with specifiers, String inspection methods (length, charAt, indexOf), comparison methods (equals, contains), manipulation methods (substring, replace, join), and StringBuilder for mutable string operations.

Part 4: Composition

Covers IS-A vs HAS-A relationships, building composite objects from simpler parts, delegation patterns, real-world composition examples (PersonalComputer, SmartKitchen), and when to prefer composition over inheritance.

Part 5: Encapsulation (Advanced)

Covers deep dive into encapsulation principles, the three problems of poor encapsulation, data validation in constructors and setters, proper access modifier usage, and the Printer challenge.

Part 6: Polymorphism

Covers compile-time vs runtime types, factory methods, type casting, instanceof operator, pattern matching (JDK 16+), Local Variable Type Inference (var), and the Car challenge demonstrating polymorphic behavior.

OOP Challenges

Two comprehensive challenges: (1) Inheritance Challenge - Worker/Employee hierarchy with SalariedEmployee and HourlyEmployee; (2) OOP Master Challenge - Burger Restaurant application using all OOP principles (composition, inheritance, encapsulation, polymorphism).


What You'll Master

  • Classes & Objects - Instance creation, memory allocation
  • Encapsulation - Access modifiers, information hiding, data validation
  • Inheritance - Class hierarchy, constructor chaining
  • Polymorphism - Runtime dispatch, factory methods, type casting
  • Abstraction - Abstract classes vs interfaces
  • Composition - HAS-A relationships, delegation over inheritance

Resources

Primary Course

Book Reference

  • Effective Java by Joshua Bloch - Chapters 2-4 (Creating & Destroying Objects, Common Methods, Classes & Interfaces)

Key Internals to Understand

  • Method dispatch mechanism (vtable)
  • How polymorphism works at runtime
  • Object creation process (memory allocation, initialization blocks, constructor execution)
  • Interface vs Abstract class performance considerations

Progress Tracker

  • Complete Tim's course sections on OOP (Section 07-08)
  • Read Effective Java Chapters 2-4
  • Write topic notes (Part 1-6)
  • Complete challenges documentation
  • Complete book reading notes
  • Synthesize final summary
  • Implement OOP-focused mini-project

Start Date: 2026-01-25 | Completed: 2026-01-26