Inheritance


Review of Interfaces

Java Interface: provides an abstract, "umbrella" type that brings together one or more classes. (The classes implement the interface.)

Implementing Interfaces: To implement an interface, a Java class must

Polymorphism and Dynamic Binding:

    AquariumObject obj;

    obj = new AquaFish(aqua);
    obj.move();

    obj = new Crab(aqua);
    obj.move();

    obj = new Seahorse(aqua);
    obj.move();

    ArrayList<AquariumObject> objects =
            new ArrayList<AquariumObject>();
    objects.add(new AquaFish(aqua));
    objects.add(new Crab(aqua));
    objects.add(new Seahorse(aqua));

    for ( AquariumObject item : objects )
        item.move();


Alyce Brady, Kalamazoo College