public class PolymorphismDemo
1: //PolymorphismDemo.java
2:
3: public class PolymorphismDemo
4: {
5: public static void main(String[] args)
6: {
7: Person[] people = new Person[5];
8:
9: people[0] = new Undergraduate("Cotty, Manny", 4910, 1);
10: people[1] = new Undergraduate("Kick, Anita", 9931, 2);
11: people[2] = new Student("DeBanque, Robin", 8812);
12: people[3] = new Undergraduate("Bugg, June", 9901, 4);
13: people[4] = new Person("Bush, George");
14:
15: for (int i=0; i<people.length; i++)
16: {
17: people[i].writeOutput();
18: System.out.println();
19: }
20:
21: /*or ...
22: for (Person p : people)
23: {
24: p.writeOutput();
25: System.out.println();
26: }
27: */
28: }
29: }