济宁蓖乒工艺品有限责任公司

當(dāng)前位置:

JAVA認(rèn)證歷年真題:SCJP考試真題和解析5

發(fā)表時(shí)間:2014/4/21 9:54:51 來(lái)源:互聯(lián)網(wǎng) 點(diǎn)擊關(guān)注微信:關(guān)注中大網(wǎng)校微信
關(guān)注公眾號(hào)

3。B

請(qǐng)查閱JAVA類(lèi)庫(kù)。getID方法的返回值是“event type”。在認(rèn)證考試中,總會(huì)有類(lèi)似的書(shū)本以外的知識(shí),這只能靠多實(shí)踐來(lái)增長(zhǎng)知識(shí)了。

4. Which statement about listener is true?

A. Most component allow multiple listeners to be added.

B. If multiple listener be add to a single component, the event only affected one listener.

C. Component don?t allow multiple listeners to be add.

D. The listener mechanism allows you to call an addXxxxListener method as many times as is needed, specifying as many different listeners as your design require.

4。A、D

控件可以同時(shí)使用多個(gè)“addXxxxListener”方法加入多個(gè)監(jiān)聽(tīng)器。并且當(dāng)多個(gè)監(jiān)聽(tīng)器加入到同一控件中時(shí),事件可以響應(yīng)多個(gè)監(jiān)聽(tīng)器,響應(yīng)是沒(méi)有固定順序的。

5.Give the following code:

public class Example{

public static void main(String args[] ){

int l=0;

do{

System.out.println(“Doing it for l is:”+l);

}while(--l>0)

System.out.println(“Finish”);

}

}

Which well be output:

A. Doing it for l is 3

B. Doing it for l is 1

C. Doing it for l is 2

D. Doing it for l is 0

E. Doing it for l is ?C1

F. Finish

5。D、F

本題主要考察考生對(duì)流程控制的掌握情況。這是當(dāng)型循環(huán),條件為真執(zhí)行,條件為假則退出。循環(huán)體至少執(zhí)行一次,故會(huì)輸出D。循環(huán)體以外的語(yǔ)句總會(huì)被執(zhí)行,故輸出F。

6. Give the code fragment:

1) switch(x){

2) case 1:System.out.println(“Test 1”);break;

3) case 2:

4) case 3:System.out.println(“Test 2”);break;

5) default:System.out.println(“end”);

6) }

which value of x would cause “Test 2” to the output:

A. 1

B. 2

C. 3

D. default

6。B.C

在開(kāi)關(guān)語(yǔ)句中,標(biāo)號(hào)總是不被當(dāng)做語(yǔ)句的一部分,標(biāo)號(hào)的作用就是做為條件判斷而已,一旦匹配成功,就執(zhí)行其后的語(yǔ)句,一直遭遇break語(yǔ)句為止。(包括default語(yǔ)句在內(nèi))

7. Give incompleted method:

1)

2) { if(unsafe()){//do something…}

3) else if(safe()){//do the other…}

4) }

The method unsafe() well throe an IOException, which completes the method of declaration when added at line one?

A. public IOException methodName()

B. public void methodName()

C. public void methodName() throw IOException

D. public void methodName() throws IOException

E. public void methodName() throws Exception

7。D、F

IOException異常類(lèi)是Exception的子類(lèi)。根據(jù)多態(tài)性的定義,IOException對(duì)象也可以被認(rèn)為是Exception類(lèi)型。還要注意在方法聲明中拋出異常應(yīng)用關(guān)鍵字“throws”。

8. Give the code fragment:

if(x>4){

System.out.println(“Test 1”);}

else if (x>9){

System.out.println(“Test 2”);}

else {

System.out.println(“Test 3”);}

Which range of value x would produce of output “Test 2”?

A. x<4

B. x>4

C. x>9

D. None

8。D

只有兩種情況:大于4時(shí)輸出“Test1”,小于等于4時(shí)輸出“Test3”。

9. Give the following method:

public void example(){

try{

unsafe();

System.out.println(“Test1”);

}catch(SafeException e){System.out.println(“Test 2”);

}finally{System.out.println(“Test 3”);}

System.out.println(“Test 4”);

Which will display if method unsafe () run normally?

A. Test 1

B. Test 2

C. Test 3

D. Test 4

9。A、C、D

在正常情況下,打印Test1、Test3、Test4;在產(chǎn)生可捕獲異常時(shí)打印Test2、Test3、Test4;在產(chǎn)生不可捕獲異常時(shí),打印Test3,然后終止程序。注意finally后面的語(yǔ)句總是被執(zhí)行。

10. Which method you define as the starting point of new thread in a class from which new the thread can be excution?

A. public void start()

B. public void run()

C. public void int()

D. public static void main(String args[])

E. public void runnable()

10。B

線(xiàn)程的執(zhí)行是從方法“run( )”開(kāi)始的,該方法是由系統(tǒng)調(diào)用的。程序員手工調(diào)用方法start(),使線(xiàn)程變?yōu)榭蛇\(yùn)行狀態(tài)

相關(guān)鏈接JAVA認(rèn)證考試報(bào)考指南  考試論壇 考試知道   考試動(dòng)態(tài)

(責(zé)任編輯:fky)

2頁(yè),當(dāng)前第1頁(yè)  第一頁(yè)  前一頁(yè)  下一頁(yè)
最近更新 考試動(dòng)態(tài) 更多>
尉氏县| 德保县| 仙游县| 左贡县| 黄大仙区| 津南区| 大足县| 邵阳市| 绿春县| 唐河县| 大连市| 汕尾市| 枣庄市| 罗定市| 中宁县| 镇巴县| 柳河县| 怀集县| 嘉鱼县| 安新县| 马鞍山市| 合作市| 巨鹿县| 阳江市| 马关县| 临汾市| 抚松县| 盘山县| 磴口县| 内丘县| 丰顺县| 涟水县| 太康县| 河曲县| 丹凤县| 田阳县| 察雅县| 台安县| 定远县| 马山县| 松滋市|