public class Main { public static void main(String[] args) { // 1. 创建一个 Person 数组,长度为 2 Person[] people = new Person[2]; // 2. 存放 Student 和 Teacher 对象 (向上转型) people[0] = new Student(); people[1] = new Teacher(); // 3. 循环调用 answer() 方法,观察多态输出 System.out.println("--- 开始回答问题 ---"); for (int i = 0; i < people.length; i++) { people[i].answer(); } } }