Lecture 3 Objectives
At the end of today's class you should
KNOW:
- That an interface is the way to represent an itemization (union of classes) in Java
- That when an instance of a class invokes a method, the method
definition lookup is dispatched to the class to which the instance belongs
- That Java programs should not have conditionals on the type of an object
(Java's method dispatch obviates the need for a conditional)
- That a method specified by an interface must be defined with the same signature in all classes
that implement the interface
BE ABLE TO:
- Design methods for unions of data in Java
Sample Exam Question:
Add a class Tiger
to the IAnimal interface. A Tiger has a
name, length, and the number of pounds of meat it consumes daily.
Develop a method hasGivenName
over IAnimals that consumes a
name and produces true if the animal has the given name. The method
produces false for animals that don't have a name.