← 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?
- A.Vector is slower than ArrayList
- B.Stack cannot store objects
- C.Stack inherits methods like inserting in the middle, which break the "last in, first out" idea
- 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 →