Search code examples
phpoopclasscar-analogy

The object oriented relationship


I was asked to describe the relationship between vehicle, car, toyota in object oriented programming term (let's say in php environment). I was stumped. Can someone help me about it? Thanks...


Solution

  • A car is a vehicle and a toyota car is a car.

    The most straightforward statement is that car could be a subclass of vehicle and a toyota car could be a subclass of car.

    Of course, Toyota could also refer to the company, in which case things would be a little different. I'm pretty sure the paragraph above is what they expected to hear, though.