- polymorphism is a very powerful tool because many related classes can be handled the same way and through the same public interface.
- java figures out which overridden method is the public interface to use
- all 'students' have a routine for calculating letter grades
public string getLetterGrade()
public void printTranscript(Student s)
- u - undergraduate
- g - graduate student
- q - special student
- these are all classes which have getLetterGrade overrides
- print transcript(u)
- print transcript(g)
- print transcript(q)
- consider an array of students
- conglomeration of undergraduate students, graduate students and others.
- how do we create the array?
Student s; Student S;
s = new Student; S= new Student(); // not legal
Graphical User Interfaces (GUI)
- so for our programs we have started on the first line, gone through every line in sequence, and terminated at the end
- windows does not work that way
- the programmer doesn't determine the order of events
- the program 'listens' for user-generated events and passes them to the event handler
- A GUI program consists largely of event handlers that respond to events
- you would almost never call event handler methods instead java calls them when the even happens