Lecture 08 - 02/03

Inheritance, Subtype Polymorphism

Hypernyms and Hyponyms

Interfaces:

public interface List61B<Item> {
void addFirst(Item x);
void addLast(Item y);
Item getFirst();
Item getLast();
Item removeLast();
Item get(int i);
void insert(Item x, int position);
int size();
default void print() {
for (int i = 0; i < size(); i = i + 1) {
System.out.print(get(i) + " ");
}
}
}
public class AList<Item> implements List61B<Item>{
...
@Override
public void addLast(Item x) {
...
...

Dynamic Method Selection:

Static Type vs. Dynamic Type