Problem sets

Exercises

Reading is not enough. Every chapter ends with a small set of problems chosen to make the ideas concrete. Try them in your editor, not in your head.

Foundations

3 problems
  • FizzBuzz
    Print 1–100; replace multiples of 3 with Fizz, 5 with Buzz, both with FizzBuzz.
  • Temperature converter
    Read a Celsius value from args and print Fahrenheit and Kelvin.
  • Prime sieve
    Implement the Sieve of Eratosthenes up to a user-supplied limit.
    ★★

Object-Oriented Java

2 problems
  • Geometry hierarchy
    Model Shape, Circle, Rectangle, and Triangle with polymorphic area/perimeter.
    ★★
  • Library catalogue
    Book, Author, Loan — model the relationships and write a checkout method.
    ★★

Collections & Generics

2 problems
  • Word frequency
    Count words in a text file using a HashMap<String, Integer>.
    ★★
  • Generic Pair<A,B>
    Implement an immutable Pair with proper equals/hashCode and a static factory.
    ★★

Modern Java

1 problems
  • Stream pipeline
    Given a List<Order>, compute revenue per customer using streams only.
    ★★★

Concurrency

1 problems
  • Virtual-thread crawler
    Fetch a list of URLs in parallel using Thread.startVirtualThread and an ExecutorService.
    ★★★