Question
Which statement about Inheritance vs Composition is the strongest interview answer?
- Composition is usually safer than inheritance when you want to reuse behavior without tightly coupling hierarchies.
- Inheritance vs Composition is mostly a naming style choice and has little effect on runtime or design.
- Inheritance vs Composition exists mainly to reduce the number of Java files in a project.
- Inheritance vs Composition matters only for frontend frameworks, not for core Java applications.
Hint
Start with the core rule behind Inheritance vs Composition.
Answer and rationale
Correct answer: A. Composition is usually safer than inheritance when you want to reuse behavior without tightly coupling hierarchies.
Composition is usually safer than inheritance when you want to reuse behavior without tightly coupling hierarchies. This is the base concept interviewers commonly test first.
Track: Java