Source of PolymorphismDemo.java


  1: public class PolymorphismDemo
  2: {
  3:         public static void main(String[] args)
  4:         {
  5:                 Person[] people = new Person[4];
  6: 
  7:                 people[0] = new Undergraduate("Cotty, Manny", 4910, 1);
  8:                 people[1] = new Undergraduate("Kick, Anita", 9931, 2);
  9:                 people[2] = new Student("DeBanque, Robin", 8812);
 10:                 people[3] = new Undergraduate("Bugg, June", 9901, 4);
 11: 
 12:                 for (Person p : people)
 13:                 {
 14:                         p.writeOutput();
 15:                         System.out.println();
 16:                 }
 17:         }
 18: }