好吊妞这里只有精品_美女视频黄a视频全免费应用_亚洲区一二三四区2021_色多多污污下载

當(dāng)前位置:

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

發(fā)表時間:2014/4/21 9:54:42 來源:互聯(lián)網(wǎng) 點擊關(guān)注微信:關(guān)注中大網(wǎng)校微信
關(guān)注公眾號

例題1:

Choose the three valid identifiers from those listed below.

A. IDoLikeTheLongNameClass

B. $byte

C. const

D. _ok

E. 3_case

解答:A, B, D

點評:Java中的標(biāo)示符必須是字母、美元符($)或下劃線(_)開頭。關(guān)鍵字與保留字不能作為標(biāo)示符。選項C中的const是Java的保留字,所以不能作標(biāo)示符。選項E中的3_case以數(shù)字開頭,違反了Java的規(guī)則。

例題2:

How can you force garbage collection of an object?

A. Garbage collection cannot be forced

B. Call System.gc().

C. Call System.gc(), passing in a reference to the object to be garbage collected.

D. Call Runtime.gc().

E. Set all references to the object to new values(null, for example).

解答:A

點評:在Java中垃圾收集是不能被強迫立即執(zhí)行的。調(diào)用System.gc()或Runtime.gc()靜態(tài)方法不能保證垃圾收集器的立即執(zhí)行,因為,也許存在著更高優(yōu)先級的線程。所以選項B、D不正確。選項C的錯誤在于,System.gc()方法是不接受參數(shù)的。選項E中的方法可以使對象在下次垃圾收集器運行時被收集。

例題3:

Consider the following class:

1. class Test(int i) {

2. void test(int i) {

3. System.out.println(“I am an int.”);

4. }

5. void test(String s) {

6. System.out.println(“I am a string.”);

7. }

8.

9. public static void main(String args[]) {

10. Test t=new Test();

11. char ch=“y”;

12. t.test(ch);

13. }

14. }

Which of the statements below is true?(Choose one.)

A. Line 5 will not compile, because void methods cannot be overridden.

B. Line 12 will not compile, because there is no version of test() that rakes a char argument.

C. The code will compile but will throw an exception at line 12.

D. The code will compile and produce the following output: I am an int.

E. The code will compile and produce the following output: I am a String.

解答:D

點評:在第12行,16位長的char型變量ch在編譯時會自動轉(zhuǎn)化為一個32位長的int型,并在運行時傳給void test(int i)方法

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

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

2頁,當(dāng)前第1頁  第一頁  前一頁  下一頁
最近更新 考試動態(tài) 更多>