abstract class Role{
private String name;
private int age;
private String sex;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
public Role() {
System.out.println("Role");
}
public abstract void play();
}
class Employee extends Role{
public int salary;
public static int ID;
public void play() {
System.out.println("Employee play"+salary);
}
public Employee() {
System.out.println("Employee");
}
public final void sing() {
System.out.println("final sing");
}
}
class Manager extends Employee{
public final String vehicle="abc";
}
class Test1{
public static void main(String[] args){
Employee employee=new Employee();
employee.salary=100;
employee.play();
employee.sing();
Manager manager=new Manager();
manager.salary=8000;
manager.play();
System.out.println(manager.vehicle);
}
}
运行结果:
Role
Employee
Employee play100
final sing
Role
Employee
Employee play8000
abc