package com.itheima8;
/**
*
* 员工类:name id pay
*
* 经理类:继承了员工,并有自己特有的奖金属性bonus。
*
* @author jjy
*
*/
abstract class Employee{
private String name;
private String id;
private double pay;
Employee(String name,String id,double pay){
this.name=name;
this.id=id;
this.pay=pay;
}
abstract void work();
}
class Manager extends Employee{
private int bonus;
Manager(String name,String id,double pay,int bonus){
super(name,id,pay);
this.bonus=bonus;
}
public void work(){
System.out.println("manage work");
}
}
class Pro extends Employee{
Pro(String name,String id,double pay){
super(name,id,pay);
}
public void work(){
System.out.println("pro work");
}
}
public class AbstractTest {
public static void main(String[] args) {
new Pro("张三","pr01",100000).work();
}
}
抽象类中abstract void work();函数默认修饰符是public吗?
|
|