package homework1; public class Monkey
{
//构造方法
Monkey(String s)
{ }
//成员方法
public void speak()
{
System.out.println("咿咿呀呀......");
}
}
package homework1; public class People extends Monkey
{
//构造方法
People(String s)
{
super(s);
} //重写父类方法speak
public void speak()
{
System.out.println("小样的,不错嘛!会说话了!");
}
public void think()
{
System.out.println("别说话,认真思考!");
}
}
package homework1; public class E
{ public static void main(String[] args)
{
//实例化对象Monkey
Monkey m = new Monkey("tom");
m.speak(); //实例化对象people
People p = new People("Xiaoming");
p.speak();
p.think(); } }