← All topics
Quiz: Composition vs Inheritance: questions with answers
10 questions, each with the answer and a short explanation.
Take the timed quiz + get a certificate →- Q1. Why did the inheritance-based CountingSet report 6 after adding 3 names?
- Q2. The problem where a subclass breaks because of hidden internal details of its parent is called:
- Q3. In the composition version, why is there no double counting?
- Q4. What does this print? (code)
- Q5. A game character needs to fly AND swim, and abilities can change during the game. Which design fits best?
- Q6. Which is a good use of inheritance?
- Q7. "Delegation" means:
- Q8. What does this print? (code)
- Q9. Why is Stack extends Vector in the JDK considered a design mistake?
- Q10. Which statement is the most accurate interview answer?