靖江突杖商务服务有限公司

當(dāng)前位置:

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

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

例題10:

Which statement or statements are true about the code listed below? Choose three.

1. public class MyTextArea extends TextArea {

2. public MyTextArea(int nrows, int ncols) {

3. enableEvents(AWTEvent.TEXT_

EVENT_MASK);

4. }

5.

6. public void processTextEvent

(TextEvent te) {

7. System.out.println(“Processing a text event.”);

8. }

9. }

A. The source code must appear in a file called MyTextArea.java

B. Between lines 2 and 3, a call should be made to super(nrows, ncols) so that the new component will have the correct size.

C. At line 6, the return type of processTextEvent() should be declared boolean, not void.

D. Between lines 7 and 8, the following code should appear: return true.

E. Between lines 7 and 8, the following code should appear: super.processTextEvent(te).

解答:A, B, E

點(diǎn)評(píng):由于類是public,所以文件名必須與之對(duì)應(yīng),選項(xiàng)A正確。如果不在2、3行之間加上super(nrows,ncols)的話,則會(huì)調(diào)用無(wú)參數(shù)構(gòu)建器TextArea(), 使nrows、ncols信息丟失,故選項(xiàng)B正確。在Java2中,所有的事件處理方法都不返回值,選項(xiàng)C、D錯(cuò)誤。選項(xiàng)E正確,因?yàn)槿绻患觭uper.processTextEvent(te),注冊(cè)的listener將不會(huì)被喚醒。

1.Which statement about the garbage collection mechanism are true?

A. Garbage collection require additional programe code in cases where multiple  threads are running.

B. The programmer can indicate that a reference through a local variable is no longer of interest.

C. The programmer has a mechanism that explicity and immediately frees the memory used by Java objects.

D. The garbage collection mechanism can free the memory used by Java Object at explection time.

E. The garbage collection system never reclaims memory from objects while are still accessible to running user threads.

1。B、E

JAVA的垃圾回收機(jī)制是通過(guò)一個(gè)后臺(tái)系統(tǒng)級(jí)線程對(duì)內(nèi)存分配情況進(jìn)行跟蹤實(shí)現(xiàn)的,對(duì)程序員來(lái)說(shuō)是透明的,程序員沒(méi)有任何方式使無(wú)用內(nèi)存顯示的、立即的被釋放。而且它是在程序運(yùn)行期間發(fā)生的。

答案B告訴我們程序員可以使一個(gè)本地變量失去任何意義,例如給本地變量賦值為“null”;答案E告訴我們?cè)诔绦蜻\(yùn)行期間不可能完全釋放內(nèi)存。

2. Give the following method:

1) public void method( ){

2) String a,b;

3) a=new String(“hello world”);

4) b=new String(“game over”);

5) System.out.println(a+b+”ok”);

6) a=null;

7) a=b;

8) System.out.println(a);

9) }

In the absence of compiler optimization, which is the earliest point the object   a refered is definitely elibile to be garbage collection.

A. before line 3

B.before line 5

C. before line 6

D.before line 7

E. Before line 9

2。D

第6行將null賦值給a以后,a以前保存的引用所指向的內(nèi)存空間就失去了作用,它可能被釋放。所以對(duì)象a可能最早被垃圾回收是在第7行以前,故選擇D選項(xiàng)。

3. In the class java.awt.AWTEvent,which is the parent class upon which jdk1.1 awt events are based there is a method called getID which phrase accurately describes the return value of this method?

A. It is a reference to the object directly affected by the cause of the event.

B. It is an indication of the nature of the cause of the event.

C. It is an indication of the position of the mouse when it caused the event.

D. In the case of a mouse click, it is an indication of the text under the mouse at the time of the event.

E. It tells the state of certain keys on the keybord at the time of the event.

F. It is an indication of the time at which the event occurred

相關(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) 更多>
兴隆县| 南阳市| 博湖县| 佳木斯市| 万安县| 永吉县| 丰宁| 民和| 广东省| 琼海市| 双辽市| 六盘水市| 休宁县| 三原县| 廉江市| 北宁市| 东兴市| 五家渠市| 洞头县| 罗定市| 祁东县| 丰都县| 普宁市| 淳化县| 石屏县| 永清县| 奈曼旗| 南涧| 新龙县| 高州市| 龙岩市| 东丽区| 延庆县| 红河县| 凌海市| 尖扎县| 彭泽县| 安康市| 赤壁市| 兴海县| 玉屏|