被6个男人灌了一夜精子_欧美chengren_欧美精品亚洲网站_女女互磨高h文

當前位置:

JAVA認證歷年真題:SCJP考試真題和解析4

發表時間:2014/4/21 9:54:49 來源:互聯網 點擊關注微信:關注中大網校微信
關注公眾號

例題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

點評:由于類是public,所以文件名必須與之對應,選項A正確。如果不在2、3行之間加上super(nrows,ncols)的話,則會調用無參數構建器TextArea(), 使nrows、ncols信息丟失,故選項B正確。在Java2中,所有的事件處理方法都不返回值,選項C、D錯誤。選項E正確,因為如果不加super.processTextEvent(te),注冊的listener將不會被喚醒。

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的垃圾回收機制是通過一個后臺系統級線程對內存分配情況進行跟蹤實現的,對程序員來說是透明的,程序員沒有任何方式使無用內存顯示的、立即的被釋放。而且它是在程序運行期間發生的。

答案B告訴我們程序員可以使一個本地變量失去任何意義,例如給本地變量賦值為“null”;答案E告訴我們在程序運行期間不可能完全釋放內存。

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以前保存的引用所指向的內存空間就失去了作用,它可能被釋放。所以對象a可能最早被垃圾回收是在第7行以前,故選擇D選項。

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

相關鏈接JAVA認證考試報考指南  考試論壇 考試知道   考試動態

(責任編輯:fky)

2頁,當前第1頁  第一頁  前一頁  下一頁
最近更新 考試動態 更多>

考試科目