新学到的继承链
简单实现继承链
分三部分,代码如下:
一部分
package Day07;
public class Employee extends Person {
public Employee() {
this ("(2) Invoke Employee's constructor");
System.out.println("(3) Perform Employee's task");
}
public Employee(String s) {
System.out.println(s);
}
}
第二部分
package Day07;
public class Faculty extends Employee {
public Faculty() {
System.out.println("(4) Perform Faculty's task");
}
public static void main(String[] args) {
new Faculty();
}
}
第三部分
package Day07;
public class Person {
public Person() {
System.out.println("(1) performs Person's task");
}
}
只相信苦尽甘来