Series 4: Object-Oriented Programming
Classes, objects, constructors, encapsulation, interfaces, Comparable, and the shift from procedural code to thinking in objects.
Lessons
4.1: What Are Objects?
~18 min · Week 8 · Prereq: Lesson 2.1
From parallel arrays to bundled data. Classes vs objects, the new keyword, object references, null, and objects you have already used (Scanner, String).
4.2: Writing Your First Class
~20 min · Week 8 · Prereq: Lesson 4.1
Fields, constructors, the this keyword, instance methods, and toString(). Building a complete Student class from scratch.
4.3: Encapsulation and Access Control
~18 min · Week 8 · Prereq: Lesson 4.2
Private fields, public methods, getters/setters with validation, and information hiding. Why encapsulation protects your objects from invalid states.
4.4: toString, equals, and hashCode
~20 min · Week 8 · Prereq: Lesson 4.3
The three methods every Java class needs. Custom toString(), equals() with instanceof, and hashCode() with Objects.hash().
4.5: Unit Testing with JUnit
~18 min · Week 9 · Prereq: Lesson 4.4
JUnit 5 basics: @Test, assertEquals, assertThrows. The Red-Green-Refactor TDD cycle and running tests with Gradle.
4.6: Interfaces and Comparable
~20 min · Week 9 · Prereq: Lesson 4.4
Interface contracts, the Comparable<T> interface, writing compareTo(), and implementing natural ordering on custom classes.
4.7: Sorting Objects
~18 min · Week 9 · Prereq: Lessons 4.6, 2.3
Arrays.sort() and Collections.sort() with Comparable objects. Selection sort on object arrays, multi-field sorting, and Comparator intro.
4.8: Objects in Memory
~20 min · Week 9 · Prereq: Lesson 4.2
Stack vs heap, object references and aliasing, == vs .equals(), null and NullPointerException, passing objects to methods, and garbage collection.
4.9: Capstone Review and APE Preparation
~22 min · Week 10 · Prereq: All previous lessons
Connecting all 10 weeks by theme. Complete integration example, the full toolkit quick reference, APE preparation tips, and what comes next in CSCD 211.
Previous series: ← Series 3: File I/O