The following Java draft does not compile because LeakAlert is incomplete. Evaluate each proposed change independently, keeping Alert and its abstract text() contract unchanged and keeping LeakAlert concrete. Each change may edit LeakAlert's declaration or add one new class; LeakAlert itself must declare no methods other than those named in the change. Select every change that makes LeakAlert compile.
abstract class Alert { public abstract String text(); public String source() { return "Water sensor"; } } class LeakAlert extends Alert { }
Declare public String text() with a body returning "Leak" directly inside LeakAlert.
Declare public LeakAlert() with an empty body that calls super() directly inside LeakAlert.
Declare public String text(int level) with a body returning "Leak" directly inside LeakAlert.
Add an abstract class TextAlert extends Alert that declares public String text() returning "Leak", and change LeakAlert to extend TextAlert.
Unlock full course notes by signing up
Which subclass declarations compile?
A Java device library contains the abstract class below. Treat each table row as a separate source file in the same package, with no other errors. Enter yes or no to indicate whether each proposed subclass declaration compiles.
Counting the remaining implementations
A Java file-processing library has the draft declarations below. Keep CsvJob concrete and directly extending CheckedJob, and leave all earlier classes unchanged. How many additional method implementations must be declared inside CsvJob for it to compile? Give the number of implementations as an exact integer, with zero decimal places.
Tracing totals through an abstract fare class
A transit app models fares with the Java classes below. The superclass Ticket is abstract: it stores the base fare through its constructor and defines total(), which relies on a surcharge() method that only the subclasses implement.
The program then runs these statements:
Give the value returned by student.total() and the value returned by peak.total(), each in dollars to two decimal places.
When the abstract superclass's constructor runs
A sensor library declares an abstract class Gauge and a concrete subclass TireGauge, as shown below. A program evaluates the expression new TireGauge(220.0). Put the initialization events for this new object in the order Java performs them.