When does the meter class get ready?

A utility company models its water meters with the Java class below. The main method of another class runs the four statements shown after it. Put the lines the program prints in the order they appear on the console.


Java
public class Meter {
    private static int made = start();
    private int reading;

    private static int start() {
        System.out.println("class ready");
        return 0;
    }

    public Meter(int r) {
        reading = r;
        made++;
        System.out.println("meter " + made + " reads " + reading);
    }

    public static void summary() {
        System.out.println(made + " meters made");
    }
}


Java
Meter.summary();
Meter m1 = new Meter(40);
Meter m2 = new Meter(15);
Meter.summary();
  1. 1.

    meter 1 reads 40

  2. 2.

    2 meters made

  3. 3.

    meter 2 reads 15

  4. 4.

    class ready

  5. 5.

    0 meters made

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 Class Attributes and Methods Questions: