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. Correct Answer Incorrect Answer
    B Composition allows objects to be created from abstract classes, while inheritance allows objects to be created from concrete classes. Correct Answer Incorrect Answer
    C Composition allows objects to have "is-a" relationships, while inheritance allows objects to have "has-a" relationships. Correct Answer Incorrect Answer
    D Composition allows objects to reuse code, while inheritance allows objects to encapsulate data. Correct Answer Incorrect Answer

    Solution

    Composition allows objects to have "is-a" relationships, while inheritance allows objects to have "has-a" relationships.

    Practice Next

    Relevant for Exams:

    ×
    ×