You are designing a system where various types of vehicles (like cars, bicycles, trucks) share common properties and behaviors but also have unique attributes. Which OOP principle would be most beneficial in this scenario?
- Encapsulation
- Inheritance
- Abstraction
- Polymorphism
Abstraction allows you to define common behaviors and attributes in a base class, while leaving the specific implementations to the derived classes. This fits well with the scenario described.
Loading...
Related Quiz
- What is the purpose of the require_once() function in PHP?
- How can we determine whether a variable is set?
- In a PHP while loop, the condition is tested ______ the code block is executed.
- What is the purpose of the substr() function in PHP?
- How can you pass a variable by reference to a function in PHP?