Course contents

Module 02

Core Java & OOP

Object-oriented Java from the ground up: classes, constructors, inheritance, interfaces, the Object contract, records, enums, Optional, functional basics, modern syntax and reflection, plus Strings and exceptions in depth.

Premium15 free lessons13 topics59 lessons & question sets59 ready

By the end of this module you can

  • Explain how objects are created, initialised and laid out, and what this and super really do
  • Choose between inheritance, composition and interfaces, and defend the choice in a design round
  • Implement equals(), hashCode() and deep copies correctly, and use records, enums and Optional the way they were designed
  • Read and write modern Java: sealed types, pattern matching for switch and functional interfaces

Classes & objects

What a class and an object really are, constructors, every way to create an object, and the this keyword.

  1. Java classes and objectsLesson · 14 minMust knowFree
  2. Concrete classes in JavaLesson · 12 minOften askedFree
  3. A guide to constructors in JavaLesson · 15 minMust knowFree
  4. A guide to creating objects in JavaLesson · 16 minOften askedPremium
  5. The this keyword in JavaLesson · 15 minOften askedPremium
  6. Access modifiersLesson · from Module 01Free
  7. Classes & objects: interview questions & scenariosInterview Q&AFree

Inheritance & polymorphism

Extending classes, super, overloading vs overriding, casting objects and instanceof.

  1. A guide to inheritance in JavaLesson · 16 minMust knowFree
  2. The super keyword in JavaLesson · 15 minOften askedFree
  3. Method overloading and overriding in JavaLesson · 15 minMust knowFree
  4. Object type casting in JavaLesson · 13 minOften askedPremium
  5. The instanceof operator in JavaLesson · 18 minOften askedPremium
  6. Inheritance & polymorphism: interview questions & scenariosInterview Q&AFree

Abstract classes & interfaces

Abstract classes, interfaces, default and static methods, and sealed hierarchies.

  1. Abstract classes in JavaLesson · 15 minMust knowFree
  2. Interfaces in JavaLesson · 13 minMust knowFree
  3. Static and default methods in interfacesLesson · 14 minOften askedPremium
  4. Sealed classes and interfacesLesson · 14 minGood to knowPremium
  5. Abstract classes & interfaces: interview questions & scenariosInterview Q&AFree

Object relationships

Is-a vs has-a, and association, aggregation and composition in real designs.

  1. Inheritance vs composition: is-a vs has-aLesson · 14 minMust knowFree
  2. Association, aggregation and compositionLesson · 14 minOften askedPremium
  3. Object relationships: interview questions & scenariosInterview Q&AFree

static, final & transient

The three modifiers that change how members live, change and get serialised.

  1. The static keyword in JavaLesson · 16 minMust knowFree
  2. The final keyword in JavaLesson · 15 minMust knowFree
  3. The transient keyword in JavaLesson · 13 minGood to knowPremium
  4. static, final & transient: interview questions & scenariosInterview Q&AFree

The Object contract

Comparing objects, the equals() and hashCode() contracts, and copying objects safely.

  1. Comparing objects in JavaLesson · 15 minMust knowFree
  2. The equals() and hashCode() contractsLesson · 15 minMust knowFree
  3. Deep copy vs shallow copy in JavaLesson · 15 minOften askedPremium
  4. Designing immutable objectsLesson · 12 minMust knowPremium
  5. The Object contract: interview questions & scenariosInterview Q&AFree

Records, enums & Optional

Java's data carriers, type-safe constants and the right way to say "maybe absent".

  1. Records in JavaLesson · 19 minOften askedPremium
  2. A guide to Java enumsLesson · 18 minOften askedPremium
  3. A guide to Java OptionalLesson · 17 minOften askedPremium
  4. Records, enums & Optional: interview questions & scenariosInterview Q&APremium

Functional Java basics

Functional interfaces, callbacks and functional programming style in Java.

  1. Functional interfaces in JavaLesson · 16 minMust knowPremium
  2. Callback functions in JavaLesson · 14 minGood to knowPremium
  3. Functional programming in JavaLesson · 17 minOften askedPremium
  4. Functional Java basics: interview questions & scenariosInterview Q&APremium

Modern Java syntax

Pattern matching for switch, and compact source files with instance main methods.

  1. Pattern matching for switchLesson · 12 minOften askedPremium
  2. Compact source files and instance main methodsLesson · 11 minGood to knowPremium
  3. Modern Java syntax: interview questions & scenariosInterview Q&APremium

Reflection & annotations

Inspecting and invoking code at runtime, annotations, and how frameworks use both.

  1. A guide to Java reflectionLesson · 15 minOften askedPremium
  2. Built-in and custom annotationsLesson · 13 minOften askedPremium
  3. How frameworks use annotations and reflectionLesson · 15 minMust knowPremium
  4. Reflection & annotations: interview questions & scenariosInterview Q&APremium

Strings in depth

Immutability, the string pool, builders and compact strings.

  1. Why String is immutableFree guide · already liveFree
  2. How Strings live in memory: the string poolLesson · 15 minMust knowPremium
  3. StringBuilder vs StringBufferLesson · 16 minMust knowPremium
  4. Interning and compact stringsLesson · 15 minOften askedPremium
  5. Strings in depth: interview questions & scenariosInterview Q&APremium

Exceptions

How exceptions work under the hood and how to use them well.

  1. How exceptions work in JavaLesson · 16 minMust knowPremium
  2. Checked vs unchecked exceptionsLesson · 14 minMust knowPremium
  3. try-with-resourcesLesson · 13 minOften askedPremium
  4. Custom exceptions and best practicesLesson · 18 minOften askedPremium
  5. Exception handling in production: the complete guideLesson · 44 minMust knowPremium
  6. Exceptions: interview questions & scenariosInterview Q&APremium

Nested types

Inner, static nested, local and anonymous classes.

  1. Inner, static nested and anonymous classesLesson · 16 minOften askedPremium
  2. Nested types: interview questions & scenariosInterview Q&APremium

Module interview question bank

Finish the module

Module interview question bank

Every interview question worth practising for Core Java & OOP, grouped by topic, with model answers, how to say them and what-if follow-ups.

45 questions · 35 what-if follow-ups13 topic question sets

Premium