Amazon Interview Question
Software Engineer / DevelopersExactly. From this URL (http://www.cs.colostate.edu/~rta/publications/Computer00.pdf), we have:
Class java.util.Stack is a subclass of
java.util.Vector. Stack defines common stack methods
such as push(), pop(), and peek(). However, because
Stack is a subclass of Vector, it inherits all the methods
Vector defines. Thus, you can supply a Stack
object wherever the program specifies a Vector object.
A program can insert or delete elements at specified
locations in a Stack object using Vector’s insert-
ElementAt or removeElementAt methods. It can even
use Vector’s removeElement method to remove a specified
element from a Stack object without regard to
the element’s position in the stack.
Is it that it extends vector, so methods from vector might be misused to disturb the stack ?
- Kx June 23, 2008