Subject: PHP

Abstract Classes

  • Create an abstract class Vehicle with properties: make, model, and year.
  • Add an abstract method calculateFuelEfficiency().
  • Create child classes Car and Motorcycle that implement the calculateFuelEfficiency() method with specific logic.
  • Instantiate the child classes and demonstrate polymorphism by calling calculateFuelEfficiency().

Select file or drag and drop

PNG, JPG, SVG

Preview