abstract class Employee
{
private String name;
private String id;
private int age;
Employee(String name,String id,int age)
{
this.name = name;
this.id = id;
this.age = age;
}
public abstract void work();
}
class Manager extends Employee
{
private int bonus;
Manager(String name,String id,int age,int bonus)
{
super(name,id,age);
this.bonus = bonus;
}
public void work()
{
System.out.println("manager work!");
}
}
class Staff extends Employee
{
Staff(String name,String id,int age)
{
super(name,id,age);
}
public void work()
{
System.out.println("staff work");
}
} 抽象类是没有实力对象的,所以应该不能调用自己的构造函数才对!但是在Employee类的子类Manager和Staff中的构造函数都掉用到了父类构造函数!!
编译和运行都没有出错!这到底是怎么回事?哪位大侠知道????
|
|