🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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 →
  1. Q1. Why did the inheritance-based CountingSet report 6 after adding 3 names?
  2. Q2. The problem where a subclass breaks because of hidden internal details of its parent is called:
  3. Q3. In the composition version, why is there no double counting?
  4. Q4. What does this print? (code)
  5. Q5. A game character needs to fly AND swim, and abilities can change during the game. Which design fits best?
  6. Q6. Which is a good use of inheritance?
  7. Q7. "Delegation" means:
  8. Q8. What does this print? (code)
  9. Q9. Why is Stack extends Vector in the JDK considered a design mistake?
  10. Q10. Which statement is the most accurate interview answer?