You are designing a car simulation game using JavaScript. Each type of car (e.g., sedan, truck, etc.) has different methods for calculating fuel efficiency. Which object-oriented programming concept would be most appropriate to ensure that each car type can calculate fuel efficiency in its own way, while still inheriting basic characteristics from a general Car class?

  • Inheritance
  • Polymorphism
  • Encapsulation
  • Abstraction
Polymorphism allows different car types (e.g., sedan, truck) to have their own implementations of the fuel efficiency calculation method while inheriting common attributes and behaviors from the general Car class. This ensures flexibility and extensibility in your game.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *