Complete the code to declare an abstract class named Vehicle.
<?php abstract class [1] { } ?>
The keyword abstract is used before the class name to declare an abstract class. The class name should be Vehicle as specified.
Complete the code to declare an abstract method named startEngine inside the abstract class.
<?php abstract class Vehicle { public abstract function [1](); } ?>
By convention, method names in PHP use camelCase. The method should be named exactly startEngine as given.
Fix the error in the code by completing the method declaration correctly.
<?php abstract class Vehicle { public abstract function [1](); } ?>
In an abstract class, to declare an abstract method, you must use the abstract keyword before the function. However, here the blank is only for the method name. The correct method declaration is public abstract function startEngine();. Since the code already has public abstract function, the blank should only be the method name startEngine.
Fill both blanks to complete the class that extends the abstract class and implements the abstract method.
<?php class Car extends [1] { public function [2]() { echo "Engine started"; } } ?>
The class Car extends the abstract class Vehicle (capitalized). It must implement the abstract method startEngine exactly as declared.
Fill all three blanks to create an instance of the class and call the implemented method.
<?php $car = new [1](); $car->[2](); echo $car instanceof [3] ? "Yes" : "No"; ?>
We create a new object of class Car, call its method startEngine, and check if it is an instance of the abstract class Vehicle.