abstract class Person { private String name; private int age; public Person(String name, int age) { this.name = name; this.age = age; } 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 abstract void want(); } class Sthdent extends Person { private int score; public Sthdent(String name, int age, int score) { super(name, age); this.score = score; } public int getScore() { return score; } public void setScore(int score) { this.score = score; } @Override public void want() { System.out.println(getName() + " 年龄:" + getAge()+" 想要" + getScore()+"分"); } } class Work extends Person { private int money; public Work(String name, int age, int money) { super(name, age); this.money = money; } public int getMoney() { return money; } public void setMoney(int money) { this.money = money; } @Override public void want() { System.out.println(getName() + " 年龄:" + getAge()+" 想要" + getMoney()+"元"); } } public class AbsDemo { public static void main(String agrs[]) { Sthdent sthdent = new Sthdent("张三",20,100); sthdent.want(); Work work = new Work("李四",42,50000); work.want(); } }