Object-oriented Java

Classes and objects, inheritance and polymorphism, interfaces, enums and records.

About 5 hours of study

Learning objectives

Lessons

  1. 1

    Classes and objects Intermediate

    Defining classes with fields, constructors and methods, creating objects with new, encapsulation with private fields and getters, this, static members, toString, and object references.

  2. 2

    Inheritance and polymorphism Intermediate

    Extending classes with extends and super, overriding methods with @Override, protected members, abstract classes and methods, polymorphism through superclass references, and instanceof with pattern matching.

  3. 3

    Interfaces, enums and records Intermediate

    Interfaces as contracts with default methods, implementing several interfaces, Comparable for natural ordering, enums with fields and methods, and records for compact immutable data classes.

Module practice

Module quiz

1. What does new do?
2. Which keyword makes a class inherit from another?
3. What does a record generate automatically?
4. Why make fields private?
5. Shape s = new Circle(); s.area() runs which method?
6. Why can a class implement several interfaces but extend only one class?

‹ Methods, arrays and stringsErrors and collections ›