【正文】
se of an error in line 6. D. Compilation of class AImpl will fail because of an error in line 2. Answer: C 考察多態(tài)性的動態(tài)綁定,如果方法的簽名相同,則返回類型應該 與超類的相同或是超類中返回類型的子類型 。 Answer: D 在內部類的外圍類外使用內部類的時候,就像上面那個 p = (new Line()).getPoint() 即 p = ()。如果刪除 16, 17, 18 行,由于局部內部類 A 在方法 testFoo()內部屏蔽了外部的內部類 A 可以看出不會對局部內部產(chǎn)生任何影響。 : 5. class Atom { 6. Atom() { (atom )。 11. (a)。錯誤,由于 Person 對象的 hashCode 返回的值都是 420,所以 HashSet 中的 Person 對象都在一個 bucket 中,組成了一條 entry 鏈表,查詢速度與 entry 鏈表的大小息息相關。 15. } 16. public int hashCode() { 17. return 420。 3. public Score(int w, int l) { wins = w。 11. (subSet)。 [java] view plain copy 1. package 。 i++) 18. if(i%2 == 0) (i)。 } 15. public void add(N added) { 16. if (min == null || () ()) 17. min = added。 15. sum += i。 ) { 14. int i = ((Integer)()).intValue()。 } 14. public N getMax() { return max。 i 613。 看下面的例子,首先移除一個 15,發(fā)現(xiàn)原始的 treeSet和 subset里面的 15 都沒了,而 treeSet加上 15 之后,原始的 treeSet 和 subset 里面的 15 又都出現(xiàn)了。 10. subSet = (TreeSetInteger) (13, true, 16, true)。//[10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20] 18. } 19. } : 1. public class Score implements ComparableScore { 2. private int wins, losses。 13. public Person(String name) { 14. = name。 D 選項: 判斷一個 HashSet 中是否存在一個 Person 對象的次數(shù)是常數(shù)次,和 map 的大小無關 。 (3)。 13. } Which three are valid on line 12? (Choose three. )A. final B. static C. native D. public E. private F. abstract G. protected Answer: A,B,D 接口中,變量默認是 public static final,而方法默認是 public,不能改變。 所以當調用 Beta 類型對象的 testFoo 方法時,將輸出第 28 行的內容, new A()調用的是局部內部類 A 的構造函數(shù),返回一個局部內部類 A 給 fubar()函數(shù),最終輸出 2。 D. p = (new Line()).getPoint() 。 21. } 22. } What is the result? A. Afoo Afoo B. Afoo Bfoo C. Bfoo Afoo D. Bfoo Bfoo E. Compilation fails. F. An exception is thrown at runtime. Answer: D 考察多態(tài)性,編譯器認為 a 是 Alpha 類型, b 是 Beta 類型 ,但是虛擬機知道 a 和 b 的真實類型是 Beta,所以調用 Beta 類的函數(shù)。 } C. static final int[] a = new int[2]{ 100,200 } 。類的初始化是按照這樣的順序進行的:首先定義域 field,然后就會執(zhí)行靜態(tài)初始化塊,然后再執(zhí)行構造函數(shù)。 } C. new Foo() { public int bar() { return 1。 : 22. StringBuilder sb1 = new StringBuilder(123)。 (abc) 。 s1 = s1 + (abc) 。 that the current directory is empty, and that the user has read and write permissions, and the following: 11. import .*。 22. } 23. } Which statement is true? A. Compilation fails. B. The file system has a new empty directory named dir. C. The file system has a new empty directory named newDir. D. The file system has a directory named dir, containing a file . E. The file system has a directory named newDir, containing a file . Answer: E 考察 包。 B. String regex = 。 6. import 。 E. df = ()。 E. import ()。 UNIX user named Bob wants to replace his chess program with a new one, but he is not sure where the old one is installed. Bob is currently able to run a Java chess program starting from his home directory /home/bob using the mand: java classpath /test:/home/bob/downloads/*.jar Bob39。 } 10. public static void main(String[] args) { 11. Icelandic i1 = new Icelandic()。 我們假設 13 行結束的時候, i1 引用的對象叫 A, i2 引用的對象叫 B, i3 引用的對象叫 C。 C. (bytes) 。 } 15. 16. public static void main(String[] args) { 17. ItemTest fa = new ItemTest(42)。 19. } 20. 21. void doStuff(int x) { 22. ( doStuff x = + x++)。 9. o = null。 13. if (check = ()) { 14. ((check = 1) +, )。 } 3. interface C extends A,B { public void cMethod()。 } class Widget extends Gadget{ Sprocket s。 key rendering algorithms, and has assigned a programmer to replace the old algorithm with the new algorithm. When the programmer begins researching the utility classes, she is happy to discover that the algorithm to be replaced exists in only one class. The programmer reviews that class39。 } F. class Man { private BestFrienddog。 ()。 } 17. } ... 30. Animal animal = new Dog()。 } 14. } Which two, independently, will allow Sub to pile? (Choose two.) A. Change line 2 to: public int a。 }調用 Sub 類的其它的構造函數(shù),也可以 public Sub() { super(5)。 9. ()。 7. } 8. } Which statement is true about the class of an object that can reference the variable base? A. It can be any class. B. No class has access to base. C. The class must belong to the geometry package. D. The class must be a subclass of the class Hypotenuse. Answer: C 考察修飾符的作用域, base 變量在類 InnerTriangle 里面,而類 InnerTriangle 的作用域是包可見性。 x[4] = 3。 x 1000000000。 } 21. catch (IOException e) { (Exception)。 。 8. o = o + x。 14. boolean b1 = true。 b1 ) 21. (3 )。 !b2 ) 18. (1 )。 13. if (str == null) { 14. (null)。 3. public static void main(String[] args) { 4. z: 5. for(int x = 2。 13. switch(x) { 14. case 2: 。 } 13. class B extends A { 14. public void process() throws IOException { 15. ()。 D. void doOne(int x) { doTwo(x)。 y 6。 QUESTION 39 Given: 1. package geometry。 5. Sub s = new Sub()。 } E. Change line 13 to: public Sub() { super(a)。 QUESTION 37 Given: 1. class Super { 2. private int a。方法具有多態(tài)性,但是域沒有多態(tài)性, f 是 Foo 類型的,所以 是 Foo 中的。 } 34. } 35. class Bar extends Foo { 36. public int a = 8。但是這里說 the programmer discovers that other classes that use the class she changed are no longer working properly. 所以肯定是沒有遵循這個原則,改變了一小部分,其他沒 動過的不能用了,說明耦合性太高了。 Sprocket s2。 Sprocket s2。 23. test(to)。在第 6 行結束時,局部變量 o和全局變量 o 都引用 A。 } 4. public void doSomething() { 5. Object o = new Object()。 : 13. public class Pass { 14. public static void main(String [] args) { 15. int x = 5。 F. SomeApp cannot use the process method in BitUtils. Answer: F private,根本就不能使用。 2. public class BitUtils { 3. private static void process(byte[] b) {} 4. } 1. package app。 i1 = i2。 : 3. interface Animal { void makeNoise()。格式 import static ...... import static 。 6. } 7. } Which code should be inserte