寒假比較有時間…繼續吧
第七十六題: |
Given: class TestA { |
What is the result? A. TestA |
答案:B |
題目範圍:物件繼承觀念 |
解析: 子代可以轉換成父代 不過本質還是子代,呼叫的方法如果存在於子代 子代的方法就會被呼叫 |
第七十七題: |
Given: public static void main(String[] args) { |
What is the result? A. 1 2 3 |
答案:A |
題目範圍:一般觀念 |
解析: 把整數陣列轉換成物件是可以的,但是整數或是其他基本資料型態不能轉成物件 以指標的觀念來看,陣列本身就是個指標,物件也是個指標 而基本資料型態本身就是值,不可以轉換成物件(指標) |
第七十八題: |
A developer is creating a class Book, that needs to access class Paper. The Paper class is deployed in a JAR named myLib.jar. Which three, taken independently, will allow the developer to use the Paper class while compiling the Book class? (Choose Three.) |
A. The JAR file is located at $JAVA_HOME/jre/classes/myLib.jar. B. The JAR file is located at $JAVA_HOME/jre/lib/ext/myLib.jar. C. The JAR file is located at /foo/myLib.jar and a classpath environment variable is set that includes /foo/myLib.jar/Paper.class. D. The JAR file is located at /foo/myLib.jar and a classpath environment variable is set that includes /foo/myLib.jar. E. The JAR file is located at /foo/myLib.jar and the Book class is compiled using javac -cp /foo/myLib.jar/Paper Book.java F. The JAR file is located at /foo/myLib.jar and the Book class is compiled using javac -d /foo/myLib.jar Book.java G. The JAR file is located at foo/myLib.jar and the Book class is compiled using javac -classpath /foo/myLib.jar Book.java |
答案:BDG |
題目範圍:編譯 |
解析: 當程式需要用引用jar檔時,你可以把jar檔放在$JAVA_HOME/jre/lib/ext/底下 或者使用classpath把程式跟jar做關聯 |
第七十九題: |
Given classes defined in two different files: package packageA; And: package packageB; |
What is the result of executing XMLMessage.main? A. text |
答案:C |
題目範圍:物件觀念 |
解析: 子代覆寫父代方法,執行時當然是執行子代的方法 |
第八十題: |
Given: interface Fish { |
What is the result? A. w-f B. f-p w-f C. w-f b-f D. f-p w-f b-f E. Compilation fails. F. An exception is thrown at runtime. |
答案:B |
題目範圍:物件觀念 |
解析: 不管物件怎麼被轉換型態,都是同一個物件 f 被轉成fish 物件,但是依然是Walleye Walleye是屬於Perch的 |
留言列表