Skip to main content

Practice · 2 of 5

Two ledgers: instance vs static (E3)

CHALLENGE
Difficulty: advanced+25 XP

Trace this class and sequence **on paper**: ``java public class Ticket { private static int issued = 0; private int id; public Ticket() { issued++; id = issued * 10; } public int getId() { return id; } public static int total() { return issued; } } ` Sequence: new Ticket(), new Ticket(), new Ticket(); then a **fourth** constructor call is skipped. Return total() + lastTicket.getId()` where lastTicket is the third ticket.

Back to lesson: Practice: Trace drills: state tables and misdirection