Class Tree · Level 5 of 7

The unfinished parent

An interface, an abstract class that uses it, and a child that fills in the blank.

<?phpinterface Shape { public function area(): float; }abstract class Base implements Shape {    public function describe(): string {        return static::class . ' area ' . $this->area();    }}class Square extends Base {    public function __construct(private float $side) {}    public function area(): float { return $this->side * $this->side; }}try {    new Base();} catch (Error $e) {    echo $e->getMessage(), "\n";}$s = new Square(3);echo $s->describe(), "\n";echo $s instanceof Shape ? 'is a Shape' : 'no', "\n";

1. Predict the output

Tap the lines in the order you think they print.

  1. 1…
  2. 2…
  3. 3…