国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

SCJP試題解析

2019-11-18 11:45:58
字體:
來源:轉載
供稿:網友

  前言
  
  無論你是個新手,還是程序設計方面的專家,你都會驚異于Sun公司java的無窮魅力。Java帶給你的并不僅僅是面向對象、開放、平臺無關、易用、安全和“Write once, run anywhere”等軟件開發方面的優勢,更重要的一點是,它提供了一種新奇的表達思想的方式,一種全新的思維模式。隨著待解決問題的規模不斷膨脹,Java徹底的面向對象思想的靈活性就會凸現出來。毋庸置疑,Java是你開發大型軟件時最得心應手的利器或是你轉行IT的入門首選。
  
  SCJP考試簡介
  
  ● 考試方式
  
  全英文試題,以電腦作答,在授權的PRometric考試中心參加考試
  
  考試編號:310-025
  
  先決條件:無
  
  考試題型:復選、填空和拖拽匹配
  
  題量:59
  
  及格標準:61%
  
  時限:120分鐘
  
  費用:1250元
  
  ● 要求具備的能力
  
  ● 使用Java編程語言創建Java應用程序和applets。
  
  ● 定義和描述垃圾搜集,安全性和Java虛擬機(JVM)。
  
  ● 描述和使用Java語言面向對象的特點。
  
  ● 開發圖形用戶界面(GUI)。利用Java支持的多種布局治理。
  
  ● 描述和使用Java的事件處理模式。
  
  ● 使用Java語言的鼠標輸入、文本、窗口和菜單窗口部件。
  
  ● 使用Java的例外處理來控制程序執行和定義用戶自己的例外事件。
  
  ● 使用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的規則。
  
  例題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中垃圾收集是不能被強迫立即執行的。調用System.gc()或Runtime.gc()靜態方法不能保證垃圾收集器的立即執行,因為,也許存在著更高優先級的線程。所以選項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)方法。
  
  例題4:
  
  Which of the following lines of code will compile without error?
  
  A.
  
  int i=0;
  
  if (i) {
  
  System.out.println(“Hi”);
  
  }
  
  B.
  
  boolean b=true;
  
  boolean b2=true;
  
  if(b==b2) {
  
  System.out.println(“So true”);
  
  }
  
  C.
  
  int i=1;
  
  int j=2;
  
  if(i==1 j==2)
  
  System.out.println(“OK”);
  
  D.
  
  int i=1;
  
  int j=2;
  
  if (i==1 & j==2)
  
  System.out.println(“OK”);
  
  解答:B, C
  
  點評:選項A錯,因為if語句后需要一個boolean類型的表達式。邏輯操作有^、&、 和 &&、,但是“&”是非法的,所以選項D不正確。
  
  例題5:
  
  Which two demonstrate a "has a" relationship? (Choose two)
  
  A. public interface Person { }
  
  public class Employee extends Person{ }
  
  B. public interface Shape { }
  
  public interface Rectandle extends Shape { }
  
  C. public interface Colorable { }
  
  public class Shape implements Colorable
  
  { }
  
  D. public class Species{ }
  
  public class Animal{private Species species;}
  
  E. interface Component{ }
  
  class Container implements Component{
  
  private Component[] children;
  
  }
  
  解答:D, E
  
  點評: 在Java中代碼重用有兩種可能的方式,即組合(“has a”關系)和繼續(“is a”關系)。“has a”關系是通過定義類的屬性的方式實現的;而“is a”關系是通過類繼續實現的。本例中選項A、B、C體現了“is a”關系;選項D、E體現了“has a”關系。
  
  例題6:
  
  Which two statements are true for the class java.util.TreeSet? (Choose two)
  
  A. The elements in the collection are ordered.
  
  B. The collection is guaranteed to be immutable.
  
  C. The elements in the collection are guaranteed to be unique.
  
  D. The elements in the collection are accessed using a unique key.
  
  E. The elements in the collection are guaranteed to be synchronized
  
  解答:A, C
  
  點評:TreeSet類實現了Set接口。Set的特點是其中的元素惟一,選項C正確。由于采用了樹形存儲方式,將元素有序地組織起來,所以選項A也正確。
  
  例題7:
  
  True or False: Readers have methods that can read and return floats and doubles.
  
  A. Ture
  
  B. False
  
  解答:B
  
  點評: Reader/Writer只處理Unicode字符的輸入輸出。float和double可以通過stream進行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
  
  點評:drawString(String str, int x, int y)方法是使用當前的顏色和字符,將str的內容顯示出來,并且最左的字符的基線從(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”);

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 吴忠市| 磐安县| 嵩明县| 开封县| 昌平区| 通辽市| 瓮安县| 潞西市| 长阳| 开化县| 独山县| 冷水江市| 始兴县| 孝昌县| 交城县| 抚松县| 青铜峡市| 墨脱县| 永清县| 皮山县| 无锡市| 和平区| 桂平市| 民丰县| 县级市| 冕宁县| 巨野县| 延津县| 萨迦县| 称多县| 嘉兴市| 汝阳县| 韶关市| 景德镇市| 从化市| 翁牛特旗| 渝中区| 巴中市| 东城区| 普陀区| 兴城市|