← 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?
- A.Inheritance should never be used
- B.Composition and inheritance are the same thing
- C.Always use inheritance to avoid duplicate code
- 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 →