本帖最后由 透过生活 于 2014-2-16 18:48 编辑
/*
看了毕老师的教程,抽象类这个事例讲解,我想知道的是:Empoyee类定义成抽象类,这样对name,id,pay,进行赋初值。抽象类不能new对象,
这样Employee(String name,String id,double pay){}如何初始化
*/
abstract class Employee{
private String name;
private String id;
private double pay;
public abstract void work();
Employee(String name,String id,double pay){
this.name= name;
this.id =id;
this.pay=pay;
}
}
class Manager extends Employee{
private int bouns;
Manager(String name,String id,double pay,int bouns){
super(name,id,pay);
this.bouns=bouns;
}
public void work(){
System.out.println("manager work");
}
}
public class javaAbstract {
public static void main(String args []){
//Employee e = new Employee("透过生活",7,77,777);抽象类不能new对象
}
}
|
|