A venue application loads this Java class for the first time. Predict its query results using the initialization rules supplied below.
public class GateSettings { private static int openingLimit = readLimit(); private static int limit = 9; public static int readLimit() { return limit; } public static int readOpening() { return openingLimit; } public static void addToLimit(int amount) { limit += amount; } }
For this problem, use these Java rules:
The application executes the following stages in order. At each stage, the queries only read values.
Complete the table with the exact integer returned by each query. The limits represent numbers of visitors.
Unlock full course notes by signing up
Object access inside a static method
A Java monitoring program uses the following class. Assume s refers to an existing Sensor object when the program calls Sensor.inspect(s). Which statements about the method are true? Select all that apply.
Tracing a credit ledger
A Java application manages a shared balance of printing credits using the class below. Assume a fresh execution and no other calls.
The following statements execute in order inside main:
What value does combined hold? Answer in credits, to the nearest whole credit.
Separate calls or combined inputs
A delivery service bills each consignment in 600 g weight units, rounding any partial unit upward. Each consignment also incurs a fixed fee of 95 cents. For the masses used in this question, this Java class implements that pricing rule:
Java integer division discards the fractional part. Two items have masses of 2750 g and 850 g. Assume combining them adds no packaging mass and is permitted by the service.
Find these four quantities as exact integers:
Booking through a shared pool
A recreation centre's Java program manages a shared pool of available admission slots. Assume a fresh execution, sequential calls, and no other code that changes availability.
The following statements execute in order inside main. The second booking requests one third of the value stored in quote; the division is exact in this execution.
Determine the final values of booked, PassPool.available, and finalQuote. Give each value in slots as an exact whole number.