欢迎来到易学考试网 易学考试官网
全部科目 > Java认证考试 > SCJP程序员认证考试

单项选择题

Given that a static method doIt() in a class Work represents work to be done, what block of code will succeed in starting a new thread that will do the work?  
CODE BLOCK a:  
Runnable r = new Runnable() {  
public void run() {  
Work.doIt();  
}  
};  
Thread t = new Thread(r);  
t.start();  
CODE BLOCK b:  
Thread t = new Thread() { 
public void start() {  
Work.doIt();  }  };  
t.start();  
CODE BLOCK c:  
Runnable r = new Runnable() {  
public void run() {  
Work.doIt();  
}  
}; 
 r.start(); 
CODE BLOCK d:  
Thread t = new Thread(new Work());  
t.start();  
CODE BLOCK e:  
Runnable t = new Runnable() { 
 public void run() {  
Work.doIt();  
}  
};  
t.run();  

    A.Code block a.
    B.Code block B.
    C.Code block c.
    D.Code block d.
    E.Code block e.

点击查看答案&解析

相关考题

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

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