🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Composition vs Inheritance: all 10 questions

Quiz: Composition vs Inheritance · Question 10 of 10

Which statement is the most accurate interview answer?

Which statement is the most accurate interview answer?

  1. A.Inheritance should never be used
  2. B.Composition and inheritance are the same thing
  3. C.Always use inheritance to avoid duplicate code
  4. D.Prefer composition by default; use inheritance for true is-a relationships with classes designed for extension
Answer & explanation

Correct answer: Prefer composition by default; use inheritance for true is-a relationships with classes designed for extension

Both are tools; composition is the safer default.

Can you get the rest right without peeking?

Take the timed Quiz: Composition vs Inheritance quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →