477,747 views
19 votes
19 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 _______

User Justin Mclean
by
3.2k points

1 Answer

10 votes
10 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 Mehran Zamani
by
2.6k points