🎙 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 9 of 10

Why is Stack extends Vector in the JDK considered a design mistake?

Why is Stack extends Vector in the JDK considered a design mistake?

  1. A.Vector is slower than ArrayList
  2. B.Stack cannot store objects
  3. C.Stack inherits methods like inserting in the middle, which break the "last in, first out" idea
  4. D.Vector is final and cannot be extended
Answer & explanation

Correct answer: Stack inherits methods like inserting in the middle, which break the "last in, first out" idea

A stack only reused Vector's storage; it is not truly a Vector, so composition was the better design.

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 →