Problem Statement
Explain the concept of composition and how it differs from inheritance.
Explanation
Composition means building complex objects by combining simpler ones. For example, a 'Car' class can have an 'Engine' object inside it. It represents a 'has-a' relationship, while inheritance represents an 'is-a' relationship. Composition promotes flexibility since components can be changed without affecting the parent class hierarchy.