精品91麻豆免费免费国产在线_男女福利视频_国产一区二区三区小向美奈子_在教室里和同桌做校园h文

當(dāng)前位置:

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

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

例題1:

Choose the three valid identifiers from those listed below.

A. IDoLikeTheLongNameClass

B. $byte

C. const

D. _ok

E. 3_case

解答:A, B, D

點(diǎn)評(píng):Java中的標(biāo)示符必須是字母、美元符($)或下劃線(_)開頭。關(guān)鍵字與保留字不能作為標(biāo)示符。選項(xiàng)C中的const是Java的保留字,所以不能作標(biāo)示符。選項(xiàng)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

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

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

點(diǎn)評(píng):在第12行,16位長的char型變量ch在編譯時(shí)會(huì)自動(dòng)轉(zhuǎn)化為一個(gè)32位長的int型,并在運(yùn)行時(shí)傳給void test(int i)方法

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

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

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