最近中文字幕完整版高清,宅男宅女精品国产av天堂,亚洲欧美日韩综合一区二区,最新色国产精品精品视频,中文字幕日韩欧美就去鲁

首頁 > 考試輔導 > 計算機考試 > JAVA認證 > JAVA認證試題集錦 > SUN認證Java2程序員考試(SCJP) 試題解析(1)

SUN認證Java2程序員考試(SCJP) 試題解析(1)

        前言  

  無論你是個新手,還是程序設計方面的專家,你都會驚異于sun公司java的無窮魅力。java帶給你的并不僅僅是面向對象、開放、平臺無關、易用、安全和“write once, run anywhere”等軟件開發(fā)方面的優(yōu)勢,更重要的一點是,它提供了一種新穎的表達思想的方式,一種全新的思維模式。隨著待解決問題的規(guī)模不斷膨脹,java徹底的面向對象思想的靈活性就會凸現出來。毋庸置疑,java是你開發(fā)大型軟件時最得心應手的利器或是你轉行it的入門首選。  

scjp考試簡介  

● 考試方式  
全英文試題,以電腦作答,在授權的prometric考試中心參加考試  
考試編號:310-025  
先決條件:無  
考試題型:復選、填空和拖拽匹配  
題量:59  
及格標準:61%  
時限:120分鐘  
費用:1250元  
● 要求具備的能力  
● 使用java編程語言創(chuàng)建java應用程序和applets。  
● 定義和描述垃圾搜集,安全性和java虛擬機(jvm)。  
● 描述和使用java語言面向對象的特點。  
● 開發(fā)圖形用戶界面(gui)。利用java支持的多種布局管理。  
● 描述和使用java的事件處理模式。  
● 使用java語言的鼠標輸入、文本、窗口和菜單窗口部件。  
● 使用java的例外處理來控制程序執(zhí)行和定義用戶自己的例外事件。  
● 使用java語言先進的面向對象特點, 包括方法重載、方法覆蓋、抽象類、接口、final、static和訪問控制。  
● 實現文件的輸入/輸出 (i/o)。  
● 使用java語言內在的線程模式來控制多線程。  
● 使用java 的sockets機制進行網絡通信。  

例題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中的標示符必須是字母、美元符($)或下劃線(_)開頭。關鍵字與保留字不能作為標示符。選項c中的const是java的保留字,所以不能作標示符。選項e中的3_case以數字開頭,違反了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í)行的。調用system.gc()或runtime.gc()靜態(tài)方法不能保證垃圾收集器的立即執(zhí)行,因為,也許存在著更高優(yōu)先級的線程。所以選項b、d不正確。選項c的錯誤在于,system.gc()方法是不接受參數的。選項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在編譯時會自動轉化為一個32位長的int型,并在運行時傳給void test(int i)方法。