package jicheng;
public class Monkey {
private String s;
public String getS() {
return s;
}
public void setS(String s) {
this.s = s;
}
public Monkey(String s) {
super();
this.s = s;
}
public void speak()
{
System.out.println(getS()+":咿咿呀呀......");
}
}
package jicheng;
public class People extends Monkey {
public People(String s) {
super(s);
}
public void speak()
{
System.out.println(getS()+":小样的,不错嘛!会说话了!");
}
public void think()
{
System.out.println(getS()+":别说话,认真思考!");
}
}
package jicheng;
public class E1 {
public static void main(String[] args) {
Monkey hou=new Monkey("猴子");
hou.speak();
People ren=new People("人");
ren.speak();
ren.think();
}
}
![](https://images2015.cnblogs.com/blog/917851/201605/917851-20160523085754991-847747186.png)