Quiz · Inheritance and interfaces · lesson 2 of 8
Quiz — overriding
Question 1 of 2
What does the program print?
<?php
class Animal
{
public function speak(): string { return 'hum'; }
}
class Dog extends Animal
{
public function speak(): string { return 'woof'; }
public function talk(): string { return parent::speak() . '!'; }
}
echo (new Dog())->speak(), ' ', (new Dog())->talk(), "\n";