首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
请写出下面程序的运行结果: public class Test extends TT{ public static void main(String args[]){ Test t=new Test("Tom."); } public Test(Strin
请写出下面程序的运行结果: public class Test extends TT{ public static void main(String args[]){ Test t=new Test("Tom."); } public Test(Strin
admin
2010-12-17
55
问题
请写出下面程序的运行结果:
public class Test extends TT{
public static void main(String args[]){
Test t=new Test("Tom.");
}
public Test(String s){
super(S);
System.out.print("How are you?");
}
public Test(){
this("I am Jack.");
}
}
class TT{
public TT(){
System.out.print("Hi!");
}
public TT(String s){
this();
System.out.print("I am" +s);
}
}
结果:______。
选项
答案
Hi! I am Tom.How are you?
解析
本题考查类的继承。(从main()方法作为程序入口,首先执行Test t=new Test("Tom.")语句,此时将调用 Test(String s)构造方法,而进入此方法后由super(s)语句来调用TT.TT(Strings),而执行this()语句将会调用TT.TT(),因此,首先由System.out.print("Hi!")语句执行输出。接下来才是System.out. print("I am"+s)语句,然后才是System.out.print("How are you?"),最后程序结束。要注意区分this和super所对应的类。
转载请注明原文地址:https://kaotiyun.com/show/ZK9p777K
本试题收录于:
二级Java题库NCRE全国计算机二级分类
0
二级Java
NCRE全国计算机二级
相关试题推荐
关于面向对象和面向过程编程描述,以下选项中正确的是
下面代码的执行结果是>>>defarea(r,pi=3.14159):returnpi*r*r>>>area(pi=3.14,r=4)
二维列表ls=[[1,2,3],[4,5,6],[7,8,9]],以下选项中能获取其中元素9的是
设二叉树的中序序列为BCDA,前序序列为ABCD,则后序序列为()。
下列程序实现对ZIP文件filel4.zip的检索,在横线处填入正确的语句。packagech1;importjava.io.*;importjava.util.*;importjava.u
通过实现Rmmable接口创建线程,请在下面横线处填写代码完成此程序。publicclassThreadTest{publicstaticvoidmain(Stringargs[]){
运行字节码的三个步骤是______、校验代码、执行代码。
多线程是Java程序的________机制,它能同步共享数据、处理不同事件。
编译JavaApplication源程序文件将产生相应的字节码文件,这些字节码文件的扩展名为()。
所有由Container派生的类称为______。
随机试题
蛋白质生物合成的起始复合物中不包含
牙髓充血与浆液性牙髓炎不同点是( )
马尔科夫分析方法的基本思想是()。
规章制度是学生在学习、生活、工作中必须遵循的行为守则,它的作用不包括()。
唯物辩证法认为联系的客观性是指()。
色觉的三色理论能很好地说明()
赫尔巴特提出的三种教育方法分别是_______。
WhatIstheCoolestGasintheUniverse?WhatisthecoldestairtemperatureeverrecordedontheEarth?Wherewasthislow
ThereisonquestionbutthatNewtonwasahighlycompetentMinisterofMint.Itwasmainlythroughhisefforts【1】theEnglishcu
Completethesummarybelow.UseNOMORETHANTHREEWORDSforeachanswer.PROJECTMANAGENTLastweek’sdefinitionofpro
最新回复
(
0
)