Inheritance
Interfaces
Polymorphism
Error Handling in Java
Practice
Assignment
Back end Track
Week 2 Overview
Week 1 gave you the foundation of Java: how the language works, how to structure a program, and how to model real-world things using classes and objects. You wrote working programs — but all the logic lived in a single layer of classes.
Week 2 goes deeper. You will learn how classes and objects can relate to each other, share behaviour, and communicate through contracts. By the end of this week, you will write code that is not just correct — it is extensible, flexible, and resilient to failure.
These are the core principles that separate production-quality Java from beginner code. Every Java backend system you will ever work on — Spring Boot APIs, database layers, microservices — is built on exactly these ideas.
Learning goals
Inheritance
- Model "is-a" relationships using the
extends keyword
- Know what is inherited from a superclass and what is not
- Call parent constructors and methods using
super
- Override methods in subclasses and explain why
@Override matters
- Distinguish method overriding from method overloading
- Understand that every Java class implicitly extends
Object
Interfaces
- Define an interface as a contract — method signatures without implementation
- Implement one or more interfaces in a class using
implements
- Write
default and static methods in interfaces
- Choose between an interface and an abstract class for a given design problem
- Apply interface segregation to keep interfaces small and focused
- Recognise and use standard library interfaces:
Comparable and Iterable
Polymorphism
- Explain the difference between compile-time and runtime polymorphism
- Declare variables using a superclass or interface type
- Understand how dynamic dispatch determines which method runs at runtime
- Write code that works with a mixed collection of objects through a common type
- Use
instanceof appropriately and know when it signals a design problem
- Apply the Open/Closed Principle: extend behaviour without modifying existing code
Exception Handling
- Explain the exception hierarchy:
Throwable → Exception → RuntimeException
- Distinguish checked from unchecked exceptions and know when to use each
- Write
try-catch, finally, and try-with-resources blocks correctly
- Throw exceptions explicitly with
throw and declare them with throws
- Create custom exception classes that carry meaningful domain context
- Apply best practices: specific catches, meaningful messages, fail fast, never swallow silently
The HackYourFuture curriculum is licensed under CC BY-NC-SA 4.0
*https://hackyourfuture.net/*

Built with ❤️ by the HackYourFuture community · Thank you, contributors
Found a mistake or have a suggestion? Let us know in the feedback form.