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.
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"); } }
Meter.summary(); Meter m1 = new Meter(40); Meter m2 = new Meter(15); Meter.summary();
1.
meter 1 reads 40
2.
2 meters made
3.
meter 2 reads 15
4.
class ready
5.
0 meters made
Unlock full course notes by signing up
Tracking cart-line quantities
A Java shopping program uses the class below. In a fresh run, the statements shown execute inside main in order. Complete the table after each call using exact integer numbers of units.
Resolving two meanings of points
A Java game uses the following class to preview a player's score. Inside main, Score score = new Score(); has executed. What does score.projected(3) return? Give your answer in points, to the nearest whole point.
Moving counts through a static operation
A Java ticket office uses the class below. In a fresh run, the shown statements execute inside main, with a and b referring to distinct objects. Select every correct statement about transfer and the resulting state.
Live rate versus locked-in rate
A credit union's savings software uses the Java class below. Each account computes one year of interest two ways: with the rate shared by the whole class, and with the rate copied when the account was opened.
Another class then runs these statements:
After the last statement, find the value returned by each of x.currentInterest(), x.lockedInterest(), y.currentInterest() and y.lockedInterest(). Give each in dollars to two decimal places.