题目内容
保持下述源代码不变,增加一个Student类,使得程序运行输出:StudentEmployee部分源代码如下:class Person {void work() {System.out.println("Person");}}class Employee extends Person{void work(){System.out.println("Employee");}void work2(){System.out.println("work2");}}public class Test{public static void main(String[] args) {Person p1 = new Student();personWork(p1);Person p2 = new Employee();personWork(p2);}static void personWork(Person p) {p.work();}}
查看答案
搜索结果不匹配?点我反馈