Object-Oriented Java: Design Robust Programs

Object-Oriented Java is an intermediate-level course of 6 lessons (about 4 h), with 18 exercises and 18 quiz questions. Prerequisites: Java Fundamentals. Exercises are run and checked in a server-side sandbox.

  • Java
  • Intermediate
  • 6 lessons
  • 4 h
  • 18 exercises
  • Exercises run in a server sandbox

The course in brief

This course teaches you to design object-oriented Java programs, from your first class to a small complete domain model. You will cover encapsulation and records, inheritance and polymorphism, interfaces, sealed types and pattern matching (with the unnamed variable _ and Java 25's flexible constructors), the equals/hashCode contract, then generics and composition. All exercises are complete programs checked automatically.

What you will be able to do

  • Design encapsulated classes that guarantee their invariants
  • Use records and immutable objects to represent data
  • Use inheritance, abstract classes, and polymorphism appropriately
  • Define contracts with interfaces and model closed cases with sealed types and pattern matching
  • Correctly implement equals and hashCode and use static members
  • Write generic code and prefer composition over inheritance

Syllabus: 6 lessons

  1. 01

    Classes and Objects

    20 minFree preview
    • Define a class with fields, a constructor, and methods
    • Create objects with new and call their methods
    • Understand this, references, and null

    ClassesObjects and referencesConstructors

  2. 02

    Encapsulation, Immutability, and Records

    20 min
    • Protect an object's state with private, getters, and validation
    • Write immutable classes
    • Use records for data objects

    EncapsulationImmutabilityRecords

  3. 03

    Inheritance, Abstract Classes, and Polymorphism

    20 min
    • Create a class hierarchy with extends and super
    • Override methods with @Override
    • Use polymorphism with abstract classes

    InheritancePolymorphismAbstract classes

  4. 04

    Interfaces, Sealed Types, and Pattern Matching

    20 min
    • Define contracts with interfaces
    • Make objects comparable and sortable
    • Model closed cases with sealed types and switch pattern matching (Java 21)

    InterfacesComparable and ComparatorSealed typesPattern matching

  5. 05

    The Object Class: equals, hashCode, toString, and static Members

    20 min
    • Correctly override equals and hashCode
    • Understand their role in HashSet and HashMap
    • Use static fields and methods appropriately

    The Object classequals and hashCodestatic members

  6. 06

    Generics and Composition: Designing an Object Model

    20 min
    • Write generic classes and methods
    • Prefer composition over inheritance
    • Assemble a small, coherent object model (cart, lines, discount)

    GenericsCompositionObject design

Final project

Object-Oriented Media Library Management

Design in Java the model of a media library: documents of several types (book, DVD, magazine) with a hierarchy or a sealed interface, members, and loans with a return date and late penalties calculated according to the document type. A main program reads commands from standard input (add, borrow, return, list) and prints the results.

Deliverables

  • Java source code organized into several classes, records, and interfaces
  • A simple class diagram (image or text) justifying the choices of inheritance, interface, or composition
  • A sample commands file and the expected output
  • A README explaining compilation, execution, and the business rules

Assessment criteria

  • Strict encapsulation: private fields, validated invariants, protected internal collections
  • Polymorphism or pattern matching used for the rules specific to each document type
  • Correct equals and hashCode for entities stored in a Set or Map
  • Variable behaviors injected rather than hard-coded
  • The program handles invalid commands without stopping

Frequently asked questions

What are the prerequisites for this course?

You need to know the basics of Java: variables, conditions, loops, methods, arrays, and ArrayList, as presented in the Java Fundamentals course.

Are recent Java features covered?

Yes. The course targets Java 25, the current LTS version: records, sealed interfaces, switch and instanceof pattern matching (finalized in Java 21), the unnamed variable _ (Java 22), and flexible constructors, which allow validation before super(...) (Java 25).

What is the difference between an interface and an abstract class?

An interface defines a stateless contract that a class can implement several of; an abstract class is a single parent that can hold fields and shared code. The course explains when to choose one or the other.

Does this course prepare me for Spring Boot?

Yes. Encapsulation, interfaces, composition, and constructor injection are the foundations of Spring Boot, covered later in the Java web developer path.

This course, told for your job

Say what you want to be able to do: “Object-Oriented Java” takes its place in your path, with examples from your field. The concepts stay those of the course.

The preview is free, and you can take the courses one at a time without paying. The path only contains lessons from the catalogue.