[單項(xiàng)選擇題] 下面程序段的輸出結(jié)果是______。class Test{ public static void main(String args[ ]){
[單項(xiàng)選擇題] 下面程序段的輸出結(jié)果是______。class Test{ public static void main(String args[ ]){ MyThread t=new MyThread( ); t.displayOutput("t has been created"); t.start( ); } } class MyThread extends Thread{ public void display Output(String s){ System.out,println(s); } public void run( ){ displayOutput("t is running"); } }
A.t has been created t is running
B.t has been created
C.t is running
D.編譯錯(cuò)誤
正確答案:A解析:[分析]: 創(chuàng)建一個(gè)新的主線程對(duì)象后,通過(guò)使用start( )方法就可以啟動(dòng)此線程,線程就處于可運(yùn)行狀態(tài)Runnable。程序運(yùn)行時(shí),首先創(chuàng)建一個(gè)線程對(duì)象t,并調(diào)用displayOutput(Strings)方法輸出“t has been created”。t.start( )方法調(diào)用run( )方法,輸出“t is running”,所以正確答案為A。
詞條內(nèi)容僅供參考,如果您需要解決具體問(wèn)題
(尤其在法律、醫(yī)學(xué)等領(lǐng)域),建議您咨詢(xún)相關(guān)領(lǐng)域?qū)I(yè)人士。