Two files contain the following Java code (exactly as it appears here, there is nothing else in the files). The files are compiled by the Java compiler and the resulting Java program is run.
// Ticket.java public class Ticket { static int n = 0; public static void total() { System.out.println(n + " tickets have been issued"); } int ticket; public Ticket() { ticket = n; n++; } public void speak() { System.out.println("I have ticket " + ticket); } } // TicketDemo.java public class TicketDemo { public static void main(String[] args) { Ticket a, b, c; Ticket.total(); a = new Ticket(); a.speak(); Ticket.total(); b = new Ticket(); b.speak(); Ticket.total(); c = new Ticket(); c.speak(); Ticket.total(); } }