广元煌褂旅行社

當(dāng)前位置:

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

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

例題7:

True or False: Readers have methods that can read and return floats and doubles.

A. Ture

B. False

解答:B

點(diǎn)評: Reader/Writer只處理Unicode字符的輸入輸出。float和double可以通過stream進(jìn)行I/O.

例題8:

What does the following paint() method draw?

1. public void paint(Graphics g) {

2. g.drawString(“Any question”, 10, 0);

3. }

A. The string “Any question?”, with its top-left corner at 10,0

B. A little squiggle coming down from the top of the component.

解答:B

點(diǎn)評:drawString(String str, int x, int y)方法是使用當(dāng)前的顏色和字符,將str的內(nèi)容顯示出來,并且最左的字符的基線從(x,y)開始。在本題中,y=0,所以基線位于最頂端。我們只能看到下行字母的一部分,即字母‘y’、‘q’的下半部分。

例題9:

What happens when you try to compile and run the following application? Choose all correct options.

1. public class Z {

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

3. new Z();

4. }

5.

6. Z() {

7. Z alias1 = this;

8. Z alias2 = this;

9. synchronized(alias1) {

10. try {

11. alias2.wait();

12. System.out.println(“DONE WAITING”);

13. }

14. catch (InterruptedException e) {

15. System.out.println(“INTERR

UPTED”);

16. }

17. catch (Exception e) {

18. System.out.println(“OTHER EXCEPTION”);

19. }

20. finally {

21. System.out.println

(“FINALLY”);

22. }

23. }

24. System.out.println(“ALL DONE”);

25. }

26. }

A. The application compiles but doesn't print anything.

B. The application compiles and print “DONE WAITING”

C. The application compiles and print “FINALLY”

D. The application compiles and print “ALL DONE”

E. The application compiles and print “INTERRUPTED”

解答:A

點(diǎn)評:在Java中,每一個(gè)對象都有鎖。任何時(shí)候,該鎖都至多由一個(gè)線程控制。由于alias1與alias2指向同一對象Z,在執(zhí)行第11行前,線程擁有對象Z的鎖。在執(zhí)行完第11行以后,該線程釋放了對象Z的鎖,進(jìn)入等待池。但此后沒有線程調(diào)用對象Z的notify()和notifyAll()方法,所以該進(jìn)程一直處于等待狀態(tài),沒有輸出

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

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

2頁,當(dāng)前第1頁  第一頁  前一頁  下一頁
最近更新 考試動態(tài) 更多>
济南市| 邮箱| 凌源市| 齐齐哈尔市| 富民县| 和硕县| 贡嘎县| 大英县| 新巴尔虎左旗| 贵溪市| 金秀| 娄底市| 灌云县| 东乡族自治县| 会同县| 抚顺市| 凭祥市| 伊金霍洛旗| 葵青区| 罗田县| 西畴县| 镇安县| 收藏| 合肥市| 怀远县| 武陟县| 龙江县| 东源县| 香格里拉县| 忻州市| 迁西县| 仁怀市| 青岛市| 西丰县| 宜州市| 山西省| 河源市| 河西区| 东宁县| 临泉县| 甘洛县|