🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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?

  1. A.A car is not a kind of engine; it has an engine, so composition fits
  2. B.Java does not allow classes named Engine
  3. C.Inheritance is never allowed in Java
  4. 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 →