欢迎来到在线考试题库网 在线考试题库官网
logo

未知题型

下列程序的运行结果是______。 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毫秒结束

    A.i
    B.currentThread().sleep(i);
    C.err.println(iE.tString());
    D.out.println('线程'
    E.currentThread()
    F.getName
    G.start();
    H.线程t睡眠了300毫秒结束
    B.线程Thread-0睡眠了300毫秒结束
    C.线程t睡眠了i毫秒结束
【参考答案】

A
解析:由于类C14实现了Runnable接口,没有继承类Thread,因此需要调用 Thread.curre......

(↓↓↓ 点击下方‘点击查看答案’看完整答案 ↓↓↓)

点击查看答案
微信小程序免费搜题
微信扫一扫,加关注免费搜题

微信扫一扫,加关注免费搜题