← Quiz: Object Relationships: all 10 questions
Quiz: Object Relationships · Question 9 of 10
Why is class Car extends Engine a design mistake?
Why is class Car extends Engine a design mistake?
- A.A car is not a kind of engine; it has an engine, so composition fits
- B.Java does not allow classes named Engine
- C.Inheritance is never allowed in Java
- D.Engine must be an interface
Answer & explanation
Correct answer: A car is not a kind of engine; it has an engine, so composition fits
Use inheritance only for true is-a relationships.
Can you get the rest right without peeking?
Take the timed Quiz: Object Relationships quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →