28.4k views
16 votes
A program has a class Potato , which is derived from the class Vegetable , which is derived from the class Food . This is an example of _______

1 Answer

13 votes
Inheritance

If you have a potato, it has the features/characteristics of a vegetable
A potato is healthy, and it gets this from being a vegetable
A vegetable gets its features/characteristics from food
A vegetable can be eaten, just like food
We can then say that a vegetable inherits the ability to be eaten from food
And that the potato inherits this from being a vegetable
The potato class inherits from the vegetable class the healthiness, but the vegetable class doesn’t inherit healthiness from the food class
User Andolsi Zied
by
8.6k points

No related questions found