Question

When should you use inheritance over composition?

A When you want to reuse code without establishing an "is-a" relationship.
B When the relationship between classes is "has-a".
C When the subclass is a specialized type of the superclass ("is-a" relationship).
D When you need to achieve multiple inheritance of implementation.
E When you want to avoid polymorphism.
Practice Next

Hey! Ask a query