【正文】
b1 ) 21. (3 )。 !b2 ) 18. (1 )。 14. boolean b1 = true。 13. if (str == null) { 14. (null)。 8. o = o + x。 3. public static void main(String[] args) { 4. z: 5. for(int x = 2。 。 13. switch(x) { 14. case 2: 。 } 21. catch (IOException e) { (Exception)。 } 13. class B extends A { 14. public void process() throws IOException { 15. ()。 x 1000000000。 D. void doOne(int x) { doTwo(x)。 x[4] = 3。 y 6。 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 的作用域是包可見性。 QUESTION 39 Given: 1. package geometry。 9. ()。 5. Sub s = new Sub()。 }調(diào)用 Sub 類的其它的構(gòu)造函數(shù),也可以 public Sub() { super(5)。 } E. Change line 13 to: public Sub() { super(a)。 } 14. } Which two, independently, will allow Sub to pile? (Choose two.) A. Change line 2 to: public int a。 QUESTION 37 Given: 1. class Super { 2. private int a。 } 17. } ... 30. Animal animal = new Dog()。方法具有多態(tài)性,但是域沒有多態(tài)性, f 是 Foo 類型的,所以 是 Foo 中的。 ()。 } 34. } 35. class Bar extends Foo { 36. public int a = 8。 } F. class Man { private BestFrienddog。但是這里說 the programmer discovers that other classes that use the class she changed are no longer working properly. 所以肯定是沒有遵循這個(gè)原則,改變了一小部分,其他沒 動(dòng)過的不能用了,說明耦合性太高了。 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。 Sprocket s2。 } class Widget extends Gadget{ Sprocket s。 Sprocket s2。 } 3. interface C extends A,B { public void cMethod()。 23. test(to)。 13. if (check = ()) { 14. ((check = 1) +, )。在第 6 行結(jié)束時(shí),局部變量 o和全局變量 o 都引用 A。 9. o = null。 } 4. public void doSomething() { 5. Object o = new Object()。 19. } 20. 21. void doStuff(int x) { 22. ( doStuff x = + x++)。 : 13. public class Pass { 14. public static void main(String [] args) { 15. int x = 5。 } 15. 16. public static void main(String[] args) { 17. ItemTest fa = new ItemTest(42)。 F. SomeApp cannot use the process method in BitUtils. Answer: F private,根本就不能使用。 C. (bytes) 。 2. public class BitUtils { 3. private static void process(byte[] b) {} 4. } 1. package app。 我們假設(shè) 13 行結(jié)束的時(shí)候, i1 引用的對象叫 A, i2 引用的對象叫 B, i3 引用的對象叫 C。 i1 = i2。 } 10. public static void main(String[] args) { 11. Icelandic i1 = new Icelandic()。 : 3. interface Animal { void makeNoise()。 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。格式 import static ...... import static 。 E. import ()。 6. } 7. } Which code should be inserted at line 1 of to pile and run Demo to print pizzapizza? A. import utils.*。 E. df = ()。 Which code fragment, inserted at line 23, allows the code to pile? A. df = new DateFormat()。 6. import 。 F. String regex = \\w[ \.] +。 B. String regex = 。 16. } 17. } What is the result when the programmer attempts to pile the code and run it with the mand java Converter 12? A. It is true that j==i. B. It is false that j==i. C. An exception is thrown at runtime. D. Compilation fails because of an error in line 13. Answer: D args 是一個(gè) String 類型的數(shù)組,第 13 行應(yīng)該是 int i = (args[0])。 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 考察 包。 17. try { 18. ()。 that the current directory is empty, and that the user has read and write permissions, and the following: 11. import .*。 String 類有一個(gè) concat 函數(shù), String str = (one)。 s1 = s1 + (abc) 。 s1 = (abc) 。 (abc) 。 (abc) 。 : 22. StringBuilder sb1 = new StringBuilder(123)。 4. int [][]y = x。 } C. new Foo() { public int bar() { return 1。 } 11. public class Sprite { 12. public int fubar( Foo foo ) { return ()。類的初始化是按照這樣的順序進(jìn)行的:首先定義域 field,然后就會(huì)執(zhí)行靜態(tài)初始化塊,然后再執(zhí)行構(gòu)造函數(shù)。 a[1]=200。 } C. static final int[] a = new int[2]{ 100,200 } 。 B. static final int[] a。 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)性,編譯器認(rèn)為 a 是 Alpha 類型, b 是 Beta 類型 ,但是虛擬機(jī)知道 a 和 b 的真實(shí)類型是 Beta,所以調(diào)用 Beta 類的函數(shù)。 } 16. public static void main(String[] args) { 17. Alpha a = new Beta()。 D. p = (new Line()).getPoint() 。} 12. public Point getPoint() { return new Point()。 所以當(dāng)調(diào)用 Beta 類型對象的 testFoo 方法時(shí),將輸出第 28 行的內(nèi)容, new A()調(diào)用的是局部內(nèi)部類 A 的構(gòu)造函數(shù),返回一個(gè)局部內(nèi)部類 A 給 fubar()函數(shù),最終輸出 2。 14. new Rock(granite )。 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 接口中,變量默認(rèn)是 public static final,而方法默認(rèn)是 public,不能改變。 14. (a)。 (3)。 : 5. import .*。 D 選項(xiàng): 判斷一個(gè) HashSet 中是否存在一個(gè) Person 對象的次數(shù)是常數(shù)次,和 map 的大小無關(guān) 。所以說,刪除一個(gè)鍵對應(yīng)的 Person 對象并不會(huì)刪除所有的條目,他們的 key 都不同嘛。 13. public Person(String name) { 14. = name。 } 5. public int getLosses() { return losses。//[10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20] 18. } 19. } : 1. public class Score implements ComparableScore { 2. private int wins, loss