public class OO {
  
  public static void main(String[] args){
    
    Student[] a = new Student[3];
    a[0] = new Student("s1", 1000);
    a[1] = new StudentAthlete("s2", 2000, "Swimming");
    a[2] = new StudentNerd("s3", 3000, 8);
    
    for (int i = 0; i < 3; i++){
      System.out.println(a[i].toString());
    }
    
    // a[2].readBook();  // why doesn't this work?
    ((StudentNerd) a[2]).readBook();
    
    for (int i = 0; i < 3; i++){
      System.out.println(a[i].toString());
    }
    
    //( (StudentNerd) a[1]).readBook();  // what's the problem?
    
    Student s = a[1];
    System.out.println(s); // what is printed? from Student or StudentAthlete?
    
  }
}