编写一个 Java应用程序, 该程序中包含 3 个类: Ape类、 People类和主类A。
packagepractice1;classApe{privateintnumb;Ape(intn){numb=n;}[代码1]//在类Ape定义构造方法,形成重载pub...
package practice1;
class Ape{
private int numb;
Ape(int n){
numb = n;
}
[代码1]//在类Ape定义构造方法,形成重载
public void speak(){
System.out.println("oh ooh yeah yeah");
}
public int getNumb(){
return numb;
}
}
class People extends Ape{
String name ;
People(String name)
name = s;
}
【代码2】//在子类中重写实例方法speak()
public void think(){
System.out.println("I also can think.");
}
public class A {
public static void main(String[] args) {
// TODO Auto-generated method stub
Ape ape = new Ape(1);
System.out.println("ape"+【代码3】//获得对象ape的成员变量numb值//+“;”);
ape.speak();
People people = new People("zhangsan");
System.out.print(people.name+";");
people.speak();
System.out.print(people.name+";");
[代码4]//通过对象调用think()方法
}
} 展开
class Ape{
private int numb;
Ape(int n){
numb = n;
}
[代码1]//在类Ape定义构造方法,形成重载
public void speak(){
System.out.println("oh ooh yeah yeah");
}
public int getNumb(){
return numb;
}
}
class People extends Ape{
String name ;
People(String name)
name = s;
}
【代码2】//在子类中重写实例方法speak()
public void think(){
System.out.println("I also can think.");
}
public class A {
public static void main(String[] args) {
// TODO Auto-generated method stub
Ape ape = new Ape(1);
System.out.println("ape"+【代码3】//获得对象ape的成员变量numb值//+“;”);
ape.speak();
People people = new People("zhangsan");
System.out.print(people.name+";");
people.speak();
System.out.print(people.name+";");
[代码4]//通过对象调用think()方法
}
} 展开
1个回答
展开全部
代码1: Ape(){}
代码2:
@Override
public void speak(){
System.out.println("oh yes");
}
代码3:ape.getNumb()
代码4:people.think();
代码2:
@Override
public void speak(){
System.out.println("oh yes");
}
代码3:ape.getNumb()
代码4:people.think();
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |