Repairing a concrete class without weakening its contract

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.


Java
abstract class Alert {
    public abstract String text();

    public String source() {
        return "Water sensor";
    }
}

class LeakAlert extends Alert { }
Choose an answer

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 Abstract Methods and Abstract Classes Questions: