Introduction to OOP Chapter 10: Subclasses and Subtypes: next previous audio real text

The Problem of Defining Types

Consider how we might define a Stack ADT:
interface Stack {
	public void push (Object value);
	public Object top ();
	public void pop ();
}
Notice how the interface itself says nothing about the LIFO property, which is the key defining feature of a stack. Is the following a stack?
class NonStack implements Stack {
	public void push (Object value) { v = value; }
	public Object top () { return v; }
	public void pop () { v = null; }

	private Object v = null;
}
Intro OOP, Chapter 10, Slide 04