现有两个类,父类为Person,子类为Chinese,Person中有如下的定义片段:
……
Stringname="noname";
publicPerson(){name="one man";}
publicPerson(String tmpname){name=tmpname;}
……
Chinese中有如下的定义片段:
……
publicChinese(int tmpage)
{
if(tmpage>=18)
{super();}
else
{super("achild");}
}
public StringgetName()
{
return name;
}
……
第三个类Demo是这样定义的:
publicclass Demo
{
public static void main(String args[])
{
Chinese c=new Chinese(25);
System.out.println("Thischinese's name is:"+c.getName());
}
}
程序进行编译执行时,会产生什么样的执行结果?
a.This chinese's name is:a man
b.This chinese's name is:a child
c.This chinese's name is:noname
d.编译运行过程出错
人气:291 ℃ 时间:2019-10-08 10:30:46
解答
这个程序编译都通不过
推荐
- 前面有个Person类,Person p1=(Person)o1;(这句是什么意思)?
- 1.定义一个person类,包括姓名,性别,年龄等必要的属性; 2.定义一个继承person的子类,增加一个学号属,
- 已知类person是类student的父类,以下数组定义和赋值哪些是正确的( ).
- 左边是木字旁右边上边一个立下边一个口念什么字啊?
- 机械硬盘接口有哪些
- 有一批人合买一条船,后有10人退出,经过计算,剩下的人买船每人要多拿出一元,
- 我会尽力让你们看到,我们和其他人不一样用英语怎么说
- If you can open the box,I can close it.这一句是虚拟吗?
猜你喜欢