// Show how overridden methods in an // inheritance class exhibit virtual // behavior. public class Virtual { public static void main(String[ ] args) { Person[ ] p = new Person[6]; p[0] = new Person("Alice", 'F', 23); p[1] = new Executive("David", 'M', 45, 33333, 250000, 130000); p[2] = new Employee("Susan", 'F', 38, 44444, 65000); p[3] = new Person("Charles", 'M', 26); p[4] = new Employee("Max", 'M', 30, 55555, 78000); p[5] = new Executive("Jessica", 'F', 41, 66666, 230000, 90000); for(int i = 0; i < p.length; i++) System.out.println(p[i]); System.out.println( ); Employee[ ] e = new Employee[3]; e[0] = (Employee) p[1]; e[1] = (Employee) p[2]; e[2] = (Employee) p[4]; e[3] = (Employee) p[5]; for(int i = 0; i < e.length; i++) System.out.println(e[i].getCompensation( )); System.out.println( ); } }