3。B
請查閱JAVA類庫。getID方法的返回值是“event type”。在認證考試中,總會有類似的書本以外的知識,這只能靠多實踐來增長知識了。
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
控件可以同時使用多個“addXxxxListener”方法加入多個監(jiān)聽器。并且當多個監(jiān)聽器加入到同一控件中時,事件可以響應多個監(jiān)聽器,響應是沒有固定順序的。
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
本題主要考察考生對流程控制的掌握情況。這是當型循環(huán),條件為真執(zhí)行,條件為假則退出。循環(huán)體至少執(zhí)行一次,故會輸出D。循環(huán)體以外的語句總會被執(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
在開關語句中,標號總是不被當做語句的一部分,標號的作用就是做為條件判斷而已,一旦匹配成功,就執(zhí)行其后的語句,一直遭遇break語句為止。(包括default語句在內)
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異常類是Exception的子類。根據(jù)多態(tài)性的定義,IOException對象也可以被認為是Exception類型。還要注意在方法聲明中拋出異常應用關鍵字“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時輸出“Test1”,小于等于4時輸出“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;在產生可捕獲異常時打印Test2、Test3、Test4;在產生不可捕獲異常時,打印Test3,然后終止程序。注意finally后面的語句總是被執(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
線程的執(zhí)行是從方法“run( )”開始的,該方法是由系統(tǒng)調用的。程序員手工調用方法start(),使線程變?yōu)榭蛇\行狀態(tài)
相關鏈接:JAVA認證考試報考指南 考試論壇 考試知道 考試動態(tài)
(責任編輯:fky)