首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
下列程序的运行结果是______。 Class C14 implements Runnable { private int i; public C14(int n) { this.i = n;
下列程序的运行结果是______。 Class C14 implements Runnable { private int i; public C14(int n) { this.i = n;
admin
2010-02-22
23
问题
下列程序的运行结果是______。 Class C14 implements Runnable { private int i; public C14(int n) { this.i = n; } public void run{) { try { Thread.currentThread().sleep(i); } catch(InterruptedException ie) { System.err.println(ie.tString()); } System.out.println("线程" + Thread.currentThread() .getName + "睡眠了" + i + "毫秒结束"); } } public class Testl4 { public static void main(String[] args) { Thread t = new Thread(new C14(300), "t"); t.start(); } }
选项
A、线程t睡眠了300毫秒结束
B、线程Thread-0睡眠了300毫秒结束
C、线程t睡眠了i毫秒结束
D、线程Thread-0睡眠了i毫秒结束
答案
1
解析
由于类C14实现了Runnable接口,没有继承类Thread,因此需要调用 Thread.currentThread()方法来返回当前线程的引用。在main()方法中,调用了类C14构造方法,其参数就是线程睡眠的时间300毫秒,而Thread类构造方法的另一个参数就是线程的名称t。
转载请注明原文地址:https://kaotiyun.com/show/ns9p777K
本试题收录于:
二级Java题库NCRE全国计算机二级分类
0
二级Java
NCRE全国计算机二级
相关试题推荐
假设表文件TEST.DBF已经在当前工作区打开,要修改其结构,可使用命令()。
在VisualFoxPro中,有如下程序,函数IIF()返回值是()。*程序PRIVATEX,YSTORE"男"TOXY=LEN(X)+2?IIF(Y
SQL语句中删除视图的命令是()。
在菜单设计中,可以在定义菜单名称时为菜单项指定一个访问键。规定了菜单项的访问键为“x”的菜单名称定义是()。
在数据库设计中,将E-R图转换成关系数据模型的过程属于()。
常用的黑箱测试有等价分类法、()、因果图法和错误推测法4种。
软件开发离不开系统环境资源的支持,其中必要的测试数据属于()。
栈底至栈顶依次存放元素A、B、C、D,在第五个元素E入栈前,栈中元素可以出栈,则出栈序列可能是()。
随机试题
满足顾客对某些产品的少量需求或特殊需求方面,能够发挥独特的作用的是
制造;编造n.&v.m________
Theheatingsystemherehasa(n)______temperaturecontrol.
已知曲线y=x2,求上述平面图形绕x轴旋转一周所得旋转体的体积V.
肌力测定的分级描述中,错误的是
客观环境或条件可能引发差错属于()。
经济制度
“报关单位”由__________构成。
关于资产负债表日后事项,下列说法中正确的有()。
ReadthefollowingarticleaboutaUSmanufacturerofofficesuppliesandthequestionsontheoppositepage.Foreachquesti
最新回复
(
0
)