Python Programming - Inheritance - Discussion

Discussion Forum : Inheritance - General Questions (Q.No. 17)
17.
What is the difference between composition and inheritance?
Composition allows a class to inherit from multiple classes
Inheritance allows a class to contain objects of other classes
Composition promotes code reusability through the creation of new classes
Inheritance promotes code reusability by allowing a class to inherit attributes and methods
Answer: Option
Explanation:
Inheritance is the mechanism by which one class can inherit attributes and methods from another class, while composition involves containing objects of other classes within a class.
Discussion:
Be the first person to comment on this question !

Post your comments here:

Your comments will be displayed after verification.