public class SimpleClient { public static void main(String[] args) { Person p1 = new SmartPerson(); SmartPerson p2 = new SmartPerson("Marco Pantani"); Person p3 = new OsuStudent(); SmartPerson p4 = new OsuStudent("Galileo Galilei", 14); System.out.println(p1.showInfo()); // calls SmartPerson's method System.out.println(p2.showInfo()); // calls SmartPerson's method System.out.println(p3.showInfo()); // calls OsuStudent's method System.out.println(p4.showInfo()); // calls OsuStudent's method System.out.println("======="); Person[] csePeople = new Person[10]; for (int i = 0; i < 5; i++) { csePeople[i * 2] = new SmartPerson("Fausto " + i + " Coppi"); csePeople[i * 2 + 1] = new OsuStudent("Leonardo da Vinci", i); } for (Person p : csePeople) { System.out.println(p.showInfo()); } System.out.println("Now the same loop, casting to base class:"); for (Person p : csePeople) { System.out.println(((SmartPerson) p).showInfo()); } } }