Question

What is the difference between composition and inheritance?

A Composition allows objects to inherit properties and methods from other objects, while inheritance allows objects to contain other objects.
B Composition allows objects to be created from abstract classes, while inheritance allows objects to be created from concrete classes.
C Composition allows objects to have "is-a" relationships, while inheritance allows objects to have "has-a" relationships.
D Composition allows objects to reuse code, while inheritance allows objects to encapsulate data.
Practice Next

Relevant for Exams:

Hey! Ask a query