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.


Java
abstract class Device {
    protected Device() { }

    public abstract int read();

    public String unit() {
        return "counts";
    }
}
Proposed subclass declarationCompiles: yes or no
class Probe extends Device { }
abstract class Probe extends Device { }
class Probe extends Device { public int read() { return 17; } }

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: