hqx.543>試卷(2016/02/02)

OJCP(SCJP)題庫 下載題庫

104 年 - SCJP 1-50#41416 

選擇:41題,非選:9題
立即測驗 
我要補題 回報試卷錯誤
1.Given: 35. String #name = "Jane Doe"; 36. int $age = 24; 37. Double _height = 123.5; 38. double ~temp = 37.5; Which two statements are true? (Choose two.)
(A) Line 35 will not compile.
(B) Line 36 will not compile.
(C) Line 37 will not compile.
(D) Line 38 will not compile. .

2.Given: 1. public class TestString1{ 2. public static void main(String[] args){ 3. String str = "420"; 4. str += 42; 5. System.out.print(str); 6. } 7. } What is the output?
(A) 42
(B) 420
(C) 462
(D) 42042
(E) Compilation fails. F. An exception is thrown at runtime. .

3.Given: 1. public class Test{ 2. public static void main(String[] args){ 3. int x = 5; SCJP 6.0 認證教戰手冊 黃彬華著 碁峰出版 2 4. boolean b1 = true; 5. boolean b2 = false; 6. 7. if((x==4) && !b2) 8. System.out.print("1 "); 9. System.out.print("2 "); 10. if((b2=true) && b1) 11. System.out.print("3 "); 12. } 13. } What is the result?
(A) 2
(B) 3
(C) 1 2
(D) 2 3
(E) 1 2 3 F. Compilation fails. G. An exception is thrown at runtime. .

4.Given: 22. public void go(){ 23. String o = ""; 24. z: 25. for(int x=0; x<3; x++){ 26. for(int y=0; y<2; y++){ 27. if(x == 1) break; 28. if(x==2 && y==1) break z; 29. o = o + x + y; 30. } 31. } 32. System.out.println(o); 33. } What is the result when the go() method is invoked?
(A) 00
(B) 0001
(C) 000120
(D) 00012021
(E) Compilation fails. F. An exception is thrown at runtime. .

5.第5題 Given: 10. int x = 0; 11. int y = 10; 12. do{ 13. y--; 14. ++x; 15. }while(x < 5); 16. System.out.print(x + "," + y); What is the result?
(A) 5,6
(B) 5,5
(C) 6,5
(D) 6,6 .

6.第6題 Given: 1. public class Breaker{ 2. static String o = ""; 3. public static void main(String[] args){ 4. z: 5. o = o + 2; 6. for(int x=3; x<8; x++){ 7. if(x == 4) break; 8. if(x == 6) break z; 9. o = o + x; 10. } 11. System.out.println(o); 12. } 13. } What is the result?
(A) 23
(B) 234
(C) 235
(D) 2345
(E) 2357 A
(B) 23457 A
(C) Compilation fails. .

7.第7題 SCJP 6.0 認證教戰手冊 黃彬華著 碁峰出版 4 Given: 1. public class Breaker2{ 2. static String o = ""; 3. public static void main(String[] args){ 4. z: 5. for(int x=2; x<7; x++){ 6. if(x == 3) continue; 7. if(x == 5) break z; 8. o = o + x; 9. } 10. System.out.println(o); 11. } 12. } What is the result?
(A) 2
(B) 24
(C) 234
(D) 246
(E) 2346 F. Compilation fails. .

8.第8題 Given: 1. public class Spock{ 2. public static void main(String[] args){ 3. Long tail = 2000L; 4. Long distance = 1999L; 5. Long story = 1000L; 6. if((tail>distance) ^ ((story*2)==tail)) 7. System.out.print("1"); 8. if((distance+1 != tail) ^ ((story*2)==distance)) 9. System.out.print("2"); 10. } 11. } What is the result?
(A) 1
(B) 2
(C) 12
(D) Compilation fails.
(E) No output is produced. F. An exception is thrown at runtime. .

9.第9題 Given: 11. String[] elements = {"for", "tea", "too"}; 12. String first = (elements.length>0) ? elements[0] : null; What is the result?
(A) Compilation fails.
(B) An exception is thrown at runtime.
(C) The variable first is set to null.
(D) The variable first is set to elements[0].

10.第10題 Given: 1. import java.util.*; 2. public class Quest{ 3. public static void main(String[] args){ 4. String[] colors = 5. {"blue","red","green","yellow","orange"}; 6. Arrays.sort(colors); 7. int s2 = Arrays.binarySearch(colors, "orange"); 8. int s3 = Arrays.binarySearch(colors, "violet"); 9. System.out.print(s2 + "" + s3); 10. } 11. } What is the result?
(A) 2-1
(B) 2-4
(C) 2-5
(D) 3-1
(E) 3-4 F. 3-5 G. Compilation fails. H. An exception is thrown at runtime. .

11.第11題 Given: 1. class Alligator{ 2. public static void main(String[] args){ 3. int[]x[] = {{1,2},{3,4,5},{6,7,8,9}}; SCJP 6.0 認證教戰手冊 黃彬華著 碁峰出版 6 4. int[][]y = x; 5. System.out.print(y[2][1]); 6. } 7. } What is the result?
(A) 2
(B) 3
(C) 4
(D) 6
(E) 7 F. Compilation fails. .

12.第13題 Given: 1. public class Barn{ 2. public static void main(String[] args){ private void bar(int x){} public void bar(int x){} public int bar(String x){return 1;} public Alpha bar(int x){} public void bar(int x, int y){} public int bar(int x){return x;} Methods SCJP 6.0 認證教戰手冊 黃彬華著 碁峰出版 7 3. new Barn.go("hi", 1); 4. new Barn.go("hi", "world", 2); 5. } 6. public void go(String... y, int x){ 7. System.out.print(y[y.length-1] + " "); 8. } 9. } What is the result?
(A) hi hi
(B) hi world
(C) world world
(D) Compilation fails.
(E) An exception is thrown at runtime. .

13.第14題 Given: 11. class Person{ 12. String name = "No name"; 13. public Person(String nm){name = nm;} 14. } 15. 16. class Employee extends Person{ 17. String empID = "0000"; 18. public Employee(String id){empID = id;} 19. } 20. 21. class EmployeeTest{ 22. public static void main(String[] args){ 23. Employee e = new Employee("4321"); 24. System.out.println(e.empID); 25. } 26. } What is the result?
(A) 4321
(B) 0000
(C) An exception is thrown at runtime.
(D) Compilation fails because of an error in line 18. .

14.第15題 Given: 11. class Mud{ SCJP 6.0 認證教戰手冊 黃彬華著 碁峰出版 8 12. //insert code here 13. System.out.println("hi"); 14. } 15. } And the following five fragments: public static void main(String...a){ public static void main(String.* a){ public static void main(String... a){ public static void main(String[]... a){ public static void main(String...[] a){ How many of the code fragments, inserted independently at line 12, compile?
(A) 0
(B) 1
(C) 2
(D) 3
(E) 4 F. 5 .

15.第16題 Given: 5. class Atom{ 6. Atom(){System.out.print("atom ");} 7. } 8. class Rock extends Atom{ 9. Rock(String type){System.out.print(type);} 10. } 11. public class Mountain extends Rock{ 12. Mountain(){ 13. super("granite "); 14. new Rock("granite "); 15. } 16. public static void main(String[] a){new Mountain();} 17. } What is the result? A
(B) Compilation fails. A
(C) atom granite A
(D) granite granite A
(E) atom granite granite B
(C) An exception is thrown at runtime. B
(D) atom granite atom granite 答案:F.

16.第18題 Given: 1. class Super{ 2. private int a; 3. protected Super(int a){this.a = a;} 4. } ... 11. class Sub extends Super{ 12. public Sub(int a){super(a);} 13. public Sub(){this.a = 5;} 14. } Which two, independently, will allow Sub to compile? (Choose two.)
(A) Change line 2 to: public int a;
(B) Change line 2 to: protected int a;
(C) Change line 13 to: public Sub(){this(5);}
(D) Change line 13 to: public Sub(){super(5);}
(E) Change line 13 to: public Sub(){super(a);} .

17.第19題 Which Man class properly represents the relationship "Man has a best friend who is a Dog"?
(A) class Man extends Dog{}
(B) class Man implements Dog{}
(C) class Man{private BestFriend dog;}
(D) class Man{private Dog bestFriend;}
(E) class Man{private Dog;} F. class Man{private BestFriend;} .

18.第20題 A team of programmers is reviewing a proposed API for a new utility class. After some discussion, they realize that they can reduce the number of methods in the API without losing any functionality. If they implement the new design, which two OO principles will they be promoting?
(A) Looser coupling
(B) Tighter coupling
(C) Lower cohesion
(D) Higher cohesion
(E) Weaker encapsulation F. Stronger encapsulation .

19.第21題 Given: 1. class Batman{ 2. int squares = 81; 3. public static void main(String[] args){ 4. new Batman().go(); 5. } 6. void go(){ 7. incr(++squares); 8. System.out.println(squares); 9. } 10. void incr(int squares){squares += 10;} 11. } What is the result? SCJP 6.0 認證教戰手冊 黃彬華著 碁峰出版 11
(A) 81
(B) 82
(C) 91
(D) 92
(E) Compilation fails. F. An exception is thrown at runtime. .

20.第22題 Given: 1. class Pass{ 2. public static void main(String[] args){ 3. int x = 5; 4. Pass p = new Pass(); 5. p.doStuff(x); 6. System.out.print(" main x = " + x); 7. } 8. void doStuff(int x){ 9. System.out.println(" doStuff x = " + x++); 10. } 11. } What is the result?
(A) Compilation fails.
(B) An exception is thrown at runtime.
(C) doStuff x = 6 main x = 6
(D) doStuff x = 5 main x = 5
(E) doStuff x = 5 main x = 6 F. doStuff x = 6 main x = 5 .

21.第23題 A company has a business application that provides its users with many different reports: receivables reports, payables reports, revenue projects, and so on. The company has just purchased some new, state-of-the-art, wireless printers, and a programmer has been assigned the task of enhancing all of the reports to use not only the company's old printers, but the new wireless printers as well. When the programmer starts looking into the application, the programmer discovers that because of the design of the application, it is necessary to make changes to each report to support the new printers. Which two design concepts most likely explain the situation? (Choose two.)
(A) Inheritance SCJP 6.0 認證教戰手冊 黃彬華著 碁峰出版 12
(B) Low cohesion
(C) Tight coupling
(D) High cohesion
(E) Loose coupling F. Object immutablility .

22.第24題 A company that makes Computer Assisted Design(CAD) software has, within its application some utility classes that are used to perform 3D rendering tasks. The company's chief scientist has just improved the performance of one of the utility classes' 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 class's API, and replaces the old algorithm with the new algorithm, being careful that her changes adhere strictly to the class's API. Once testing has begun, the programmer discovers that other classes that use the class she changed are no longer working properly. What design flaw is most likely the cause of there new bugs?
(A) Inheritance
(B) Tight coupling
(C) Low cohesion
(D) High cohesion
(E) Loose coupling F. Object immutablility .

23.第25題 Given: 1. class ClassA{ 2. public int numberOfInstances; 3. protected ClassA(int numberOfInstances){ 4. this.numberOfInstances = numberOfInstances; 5. } 6. } 7. class ExtendedA extends ClassA{ 8. private ExtendedA(int numberOfInstances){ 9. super(numberOfInstances); 10. } 11. public static void main(String[] args){ 12. ExtendedA ext = new ExtendedA(420); 13. System.out.print(ext.numberOfInstances); SCJP 6.0 認證教戰手冊 黃彬華著 碁峰出版 13 14. } 15. } What is the result?
(A) 420 is the output
(B) An exception is thrown at runtime.
(C) All constructors must be declared public.
(D) Constructors CANNOT use the private modifier.
(E) Constructors CANNOT use the protected modifier. .

24.第27題 Given: 10. class One{ 11. void foo(){} 12. } SCJP 6.0 認證教戰手冊 黃彬華著 碁峰出版 14 13. class Two extends One{ 14. //insert method here 15. } Which three methods, inserted individually at line 14, will correctly complete class Two? (Choose three.)
(A) int foo(){/* more code here */}
(B) void foo(){/* more code here */}
(C) public void foo(){/* more code here */}
(D) private void foo(){/* more code here */}
(E) protected void foo(){/* more code here */} .

25.第28題 Given: 1. class X{ 2. X(){System.out.print(1);} 3. X(int x){ 4. this(); 5. System.out.print(2); 6. } 7. } 8. public class Y extends X{ 9. Y(){ 10. super(6); 11. System.out.print(3); 12. } 13. Y(int y){ 14. this(); 15. System.out.println(4); 16. } 17. public static void main(String[] a){new Y(5);} 18. } What is the result?
(A) 13
(B) 134
(C) 1234
(D) 2134
(E) 2143 F. 4321 .

26.第29題 Given: SCJP 6.0 認證教戰手冊 黃彬華著 碁峰出版 15 1. public class A{ 2. public void doit(){ 3. } 4. public String doit(){ 5. return "a"; 6. } 7. public double doit(int x){ 8. return 1.0; 9. } 10. } What is the result?
(A) An exception is thrown at runtime.
(B) Compilation fails because of an error in line 7.
(C) Compilation fails because of an error in line 4.
(D) Compilation succeeds and no runtime errors with class A occur. .

27.第30題 Given: 1. public class SimpleCalc{ 2. public int value; 3. public void calculate(){value += 7;} 4. } And: 1. public class MultiCalc extends SimpleCalc{ 2. public void calculate(){value -= 3;} 3. public void calculate(int multiplier){ 4. calculate(); 5. super.calculate(); 6. value *= multiplier; 7. } 8. public static void main(String[] args){ 9. MultiCalc calculator = new MultiCalc(); 10. calculator.calculate(2); 11. System.out.println("Value is: " + calculator.value); 12. } 13. } What is the result?
(A) Value is: 8
(B) Compilation fails.
(C) Value is: 12
(D) Value is: -12
(E) The code runs with no output. F. An exception is thrown at runtime. .

28.第31題 Given: 1. public class Base{ 2. public static final String FOO = "foo"; 3. public static void main(String[] args){ 4. Base b = new Base(); 5. Sub s = new Sub(); 6. System.out.print(Base.FOO); 7. System.out.print(Sub.FOO); 8. System.out.print(b.FOO); 9. System.out.print(s.FOO); 10. System.out.print(((Base)s).FOO); 11. } 12. } 13. class Sub extends Base{public static final String FOO = "bar";} What is the result?
(A) foofoofoofoofoo
(B) foobarfoobarbar
(C) foobarfoofoofoo
(D) foobarfoobarfoo
(E) barbarbarbarbar F. foofoofoobarbar G. foofoofoobarfoo .

29.第35題 Given: 10. public class Hello{ 11. String title; 12. int value; SCJP 6.0 認證教戰手冊 黃彬華著 碁峰出版 18 13. public Hello(){ 14. title += " World"; 15. } 16. public Hello(int value){ 17. this.value = value; 18. title = "Hello"; 19. Hello(); 20. } 21. } and: 30. Hello c = new Hello(5); 31. System.out.print(c.title); What is the result?
(A) Hello
(B) Hello World
(C) Compilation fails.
(D) Hello World 5
(E) The code runs with no output. F. An exception is thrown at runtime. .

30.第37題 Given: 21. abstract class C1{ 22. public C1(){System.out.print(1);} 23. } 24. class C2 extends C1{ 25. public C2(){System.out.print(2);} 26. } 27. class C3 extends C2{ 28. public C3(){System.out.print(3);} 29. } 30. public class Ctest{ 31. public static void main(String[] a){new C3();} 32. } What is the result?
(A) 3
(B) 23
(C) 32
(D) 123
(E) 321 F. Compilation fails. G. An exception is thrown at runtime. .

31.第38題 Given: 1. class One{ 2. public One foo(){return this;} 3. } 4. class Two extends One{ 5. public One foo(){return this;} 6. } 7. class Three extends Two{ 8. //insert method here 9. } Which two methods, inserted individually, correctly complete the Three class? (Choose two.)
(A) public void foo(){}
(B) public int foo(){return 3;}
(C) public Two foo(){return this;}
(D) public One foo(){return this;}
(E) public Object foo(){return this;}.

32.第39題 Given: 11. public class ItemTest{ 12. private final int id; 13. public ItemTest(int id){this.id = id;} 14. public void updateId(int newId){id = newId;} 15. 16. public static void main(String[] args){ 17. ItemTest fa = new ItemTest(42); 18. fa.updateId(69); 19. System.out.println(fa.id); 20. } 21. } Which four statments are true? (Choose four.)
(A) Compilation fails.
(B) An exception is thrown at runtime.
(C) The attribute id in the ItemTest object remains unchanged.
(D) The attribute id in the ItemTest object is modified to the new value.
(E) A new ItemTest object is created with the preferred value in the id attribute. .

33.第40題 SCJP 6.0 認證教戰手冊 黃彬華著 碁峰出版 21 Given: 1. class Foo{ 2. private int x; 3. public Foo(int x){this.x = x;} 4. public void setX(int x){this.x = x;} 5. public int getX(){return x;} 6. } 7. 8. public class Gamma{ 9. static Foo fooBar(Foo foo){ 10. foo = new Foo(100); 11. return foo; 12. } 13. public static void main(String[] args){ 14. Foo foo = new Foo(300); 15. System.out.print(foo.getX() + "-"); 16. 17. Foo fooFoo = fooBar(foo); 18. System.out.print(foo.getX() + "-"); 19. System.out.print(fooFoo.getX() + "-"); 20. 21. foo = fooBar(fooFoo); 22. System.out.print(foo.getX() + "-"); 23. System.out.print(fooFoo.getX()); 24. } 25. } What is the output?
(A) 300-100-100-100-100
(B) 300-300-100-100-100
(C) 300-300-300-100-100
(D) 300-300-300-300-100 .

34.第41題 Given: 1. public class KungFu{ 2. public static void main(String[] args){ 3. Integer x = 400; 4. Integer y = x; 5. x++; 6. StringBuilder sb1 = new StringBuilder("123"); 7. StringBuilder sb2 = sb1; 8. sb1.append("5"); 9. System.out.println((x == y) + " " + (sb1 == sb2)); 10. } 11. } What is the result? SCJP 6.0 認證教戰手冊 黃彬華著 碁峰出版 22
(A) true true
(B) false true
(C) true false
(D) false false
(E) Compilation fails. F. An exception is thrown at runtime. .

35.第42題 1. class A{ 2. public String doit(int x, int y){ 3. return "a"; 4. } 5. 6. public String doit(int... vals){ 7. return "b"; 8. } 9. } Given: 25. A a = new A(); 26. System.out.println(a.doit(4, 5)); What is the result?
(A) Line 26 prints "a" to System.out.
(B) Line 26 prints "b" to System.out.
(C) An exception is thrown at runtime.
(D) Compilation of class A will fail due to an error in line 6. .

36.第43題 Given: 1. class Plant{ 2. private String name; 3. public Plant(String name){this.name = name;} 4. public String getName(){return name;} 5. } 6. public class Tree extends Plant{ 7. public void growFruit(){} 8. public void dropLeaves(){} 9. } What statement is true?
(A) The code will compile without changes.
(B) The code will compile if public Tree(){Plant();} is added to the Tree class. SCJP 6.0 認證教戰手冊 黃彬華著 碁峰出版 23
(C) The code will compile if public Plant(){Tree();} is added to the Plant class.
(D) The code will compile if public Plant(){this("fern");} is added to the Plant class.
(E) The code will compile if public Plant(){Plant("fern");} is added to the Plant class. .

37.第44題 Given: 1. class Employee{ 2. String name; double baseSalary; 3. public Employee(String name, double baseSalary){ 4. this.name = name; 5. this.baseSalary = baseSalary; 6. } 7. } 8. public class SalesPerson extends Employee{ 9. double commission; 10. public SalesPerson(String name, 11. double baseSalary, double commission){ 12. //insert code here 13. } 14. } Which two code fragments, inserted independently at line 12, will compile? (Choose two.)
(A) super(name, baseSalary);
(B) this.commission = commission;
(C) super(); this.commission = commission;
(D) this.commission = commission; super();
(E) super(name, baseSalary); this.commission = commission; F. this.commission = commission; super(name, baseSalary); G. super(name, baseSalary, commission); .

38.第45題 Given that: Gadget has-a Sprocket and Gadget has-a Spring and Gadget is-a Widget and SCJP 6.0 認證教戰手冊 黃彬華著 碁峰出版 24 Widget has-a Sprocket Which two code fragments represent these relationships? (Choose two.)
(A) class Widget{Sprocket s;} class Gadget extends Widget{Spring s;}
(B) class Widget{} class Gadget extends Widget{Spring s1; Sprocket s2;}
(C) class Widget{Sprocket s1; Spring s2;} class Gadget extends Widget{}
(D) class Gadget{Spring s;} class Widget extends Gadget{Sprocket s;}
(E) class Gadget{} class Widget extends Gadget{Sprocket s1; Spring s2;} F. class Gadget{Spring s1; Sprocket s2;} class Widget extends Gadget{} .

39.第46題 Given: 10. public class Pizza{ 11. ArrayList toppings; 12. 13. public final void addTopping(String topping){ 14. toppings.add(topping); 15. } 16. 17. public void removeTopping(String topping){ 18. toppings.remove(topping); 19. } 20. } And: 30. class PepperoniPizza extends Pizza{ 31. public void addTopping(String topping){ 32. System.out.println("Cannot add Toppings"); 33. } 34. 35. public void removeTopping(String topping){ 36. System.out.println("Cannot remove pepperoni"); 37. } 38. } And: 50. Pizza pizza = new PepperoniPizza(); SCJP 6.0 認證教戰手冊 黃彬華著 碁峰出版 25 51. pizza.addTopping("Mushrooms"); 52. pizza.removeTopping("Pepperoni"); What is the result?
(A) Compilation fails.
(B) Cannot add Toppings
(C) The code runs with no output.
(D) A NullPointerException is thrown in Line 4. .

40.第48題 Given: 1. public class Venus{ 2. public static void main(String[] args){ 3. int[] x = {1, 2, 3}; 4. int y[] = {4, 5, 6}; 5. new Venus().go(x, y); 6. } 7. void go(int[]... z){ 8. for(int[] a : z) 9. System.out.print(a[0]); SCJP 6.0 認證教戰手冊 黃彬華著 碁峰出版 26 10. } 11. } What is the result?
(A) 1
(B) 12
(C) 14
(D) 123
(E) Compilation fails. F. An exception is thrown at runtime. .

41.第50題 Given: 1. public abstract class Shape{ 2. private int x; 3. private int y; 4. public abstract void draw(); 5. public void setAnchor(int x, int y){ 6. this.x = x; 7. this.y = y; 8. } 9. } Which two classes use the Shape class correctly? (Choose two.)
(A) public class Circle implements Shape{ private in radius; }
(B) public abstract class Circle extends Shape{ private in radius; }
(C) public class Circle extends Shape{ private in radius; public void draw(); }
(D) public abstract class Circle implements Shape{ private in radius; public void draw(); }
(E) public class Circle extends Shape{ private in radius; public void draw(){/* code here */} } F. public abstract class Circle implements Shape{ private in radius; public void draw(){/* code here */} } .

【非選題】
42.第12題 Drag and Drop(拖曳題) Add methods to the Beta class to make it compile correctly. class Alpha{ public void bar(int... x){} public void bar(int x){} } public class Beta extends Alpha{ Place here Place here Place here } private void bar(int x){} public void bar(int x){} public int bar(String x){return 1;} public Alpha bar(int x){} public void bar(int x, int y){} public int bar(int x){return x;}

【非選題】
43.第17題 Given: 1. public class Blip{ 2. protected int blipvert(int x){return 0;} 3. } 4. class Vert extends Blip{ 5. //insert code here 6. } Which five methods, inserted independently at line 5, will compile? (Choose five.)
(A) public int blipvert(int x){return 0;}
(B) private int blipvert(int x){return 0;}
(C) private int blipvert(long x){return 0;}
(D) protected long blipvert(int x){return 0;}
(E) protected int blipvert(long x){return 0;} F. protected long blipvert(long x){return 0;} G. protected long blipvert(int x, int y){return 0;}

【非選題】
44.第26題 Given: 10. interface Jumper{public void jump();} ... 20. class Animal{} ... 30. class Dog extends Animal{ 31. Tail tail; 32. } ... 40. class Beagle extends Dog implements Jumper{ 41. public void jump(){} 42. } ... 50. class Cat implements Jumper{ 51. public void jump(){} 52. } Which three are true? (Choose three.)
(A) Cat is-a Animal
(B) Cat is-a Jumper
(C) Dog is-a Animal
(D) Dog is-a Jumper
(E) Cat has-a Animal F. Beagle has-a Tail G. Beagle has-a Jumper

【非選題】
45.第32題 Given: 1. class Mammal{} 2. 3. class Raccoon extends Mammal 4. Mammal m = new Mammal(); 5. } 6. 7. class BabyRaccoon extends Mammal{} Which four statments are true? (Choose four.)
(A) Raccoon is-a Mammal.
(B) Raccoon has-a Mammal.
(C) BabyRaccoon is-a Mammal.
(D) BabyRaccoon is-a Raccoon.
(E) BabyRaccoon has-a Mammal. SCJP 6.0 認證教戰手冊 黃彬華著 碁峰出版 17 F. BabyRaccoon is-a BabyRaccoon.

【非選題】
46.第33題 Given: 2. public class Hi{ 3. void m1(){} 4. protected void m2(){} 5. } 6. class Lois extends Hi{ 7. //insert code here 8. } Which four code fragments, inserted independently at line 7, will compile? (Choose four.)
(A) public void m1(){}
(B) protected void m1(){}
(C) private void m1(){}
(D) void m2(){}
(E) pubic void m2(){} F. protected void m2(){} G. private void m2(){}

【非選題】
47.第34題 Which four statements are true? (Choose four.)
(A) Has-a relationships should never be encapsulated.
(B) Has-a relationships should be implemented using inheritance.
(C) Has-a relationships can be implemented using instance variables.
(D) Is-a relationships can be implemented using the extends keyword.
(E) Is-a relationships can be implemented using the implements keyword. F. The relationship between Movie and Actress is an example of an is-a relationship. G. An array or a collection can be used to implement a one-to-many has-a relationship.

【非選題】
48.第36題 Given: public class Doubler{ public static int doubleMe(Holder h){ return h.getAmount() * 2; } } and: public class Holder { int amount = 10; public void doubleAmount(){amount = Doubler.doubleMe(this);} public in getAmount(){return amount;} //more code here } Place the code framgmets in position to reduce the coupling between Doubler and Holder. public class Doubler{ public static int doubleMe( Place here h){ return Place here * 2; } } public class Holder { int amount = 10; public void doubleAmount(){amount = Doubler.doubleMe( Place here );} SCJP 6.0 認證教戰手冊 黃彬華著 碁峰出版 19 public in getAmount(){return amount;} //more code here } Code Fragments void Holder int Doubler h.getAmount() h this amount

【非選題】
49.第47題 Place the Types in one of the Type columns, and the Relationships in the Relationship column, to define appropriate has-a and is-a relationships: Type Relationship Type Relationship Types Place here Place here Animal is-a Dog Forest Place here Place here has-a Side Rectangle Place here Place here Tail Place here Place here Programming Book Square Tree Book Java Book Pen

【非選題】
50.第49題 Place code framgmets into position so the output is: The quantity is 420 Place here update(int quantity, int adjust){ Place here } public void callUpdate(){ int quant = 100; Place here System.out.println("The quantity is " + quant); } Code Fragments public int quantity = quantity + adjust; update(quant, 320); public void quant = update(quant, 320); public int update(int quantity, int adjust){ } public void callUpdate(){ int quant = 100; quant = update(quant, 320); System.out.println("The quantity is " + quant); }

懸賞詳解

國二公民上第一次

重新載圖20、公民老師的板書上,對於某一項民主政治的運作原則,做了如右 的摘要,請問:《OO 政治》應該會是哪一項民主政治的特色? (A)民意政治...

50 x

前往解題

104 年 - SCJP 1-50#41416-阿摩線上測驗

104 年 - SCJP 1-50#41416