- public abstract class Emp{
- private String name;
- public Emp(String name){
- this.name = name;
- }
- //setter and getter method
- public abstract void work();
- }
- class Manager extends Emp{
- private double bonus;
- public Manager(String name,double bonus){
- super(name);
- this.bonus = bonus;
- }
- public void work(){
- ...
- }
- }
复制代码 当创建Manager类的一个实例时,会调用抽象类的构造方法,抽象类不是不可以被实例化吗?
|