Trace class-scoped and object-scoped fields

A venue implements the following UML class excerpt using standard attribute-scope notation. Translate the field declarations from the diagram; those declarations are deliberately omitted from the Java fragment.


A Ticket class shows an underlined nextSerial attribute initialized to 240 and a non-underlined serial attribute.


The constructor is:


Java
Ticket() {
    serial = nextSerial;
    nextSerial++;
}


In a fresh, single-threaded run, the class is initialized once and these are the only constructor calls:


Java
Ticket first = new Ticket();
Ticket second = new Ticket();
Ticket third = new Ticket();


Immediately afterward, a debugger inspects the stored fields. Give the first ticket's serial, the third ticket's serial, and the current value of nextSerial. Enter each dimensionless value as an exact integer, with no rounding.

Your answers

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More Implementing Class Diagrams in Java Questions: