阿摩線上測驗
登入
首頁
>
OJCP(SCJP)
>
104年 - SCJP 51-100#99391
> 申論題
52. Place the code fragments in position to complete the Displayable interface.
相關申論題
53. Insert six modifiers into the code such that it meets all of these requirements: 1. It must be possible to create instances of Alpha and Beta from outside the packages in which they are defined. 2. When an object of type Alpha (or any potential subclass of Alpha) has been created, the instance variable alpha may never be changed. 3. The value of the instance variable alpha must always be "A" for objects of type Alpha.
#415595
63. Given: 11. class ClassA{} 12. class ClassB extends ClassA{} 13. class ClassC extends ClassA{} and: 21. ClassA p0 = new ClassA(); 22. ClassB p1 = new ClassB(); 23. ClassC p2 = new ClassC(); 24. ClassA p3 = new ClassB(); 25. ClassA p4 = new ClassC(); Which three are valid? (Choose three.) (A) p0 = p1; (B) p1 = p2, (C) p2 = p4; (D) p2 = (ClassC)p1; (E) p1 = (ClassB)p3; (F) p2 = (ClassC)p4;
#415596
64. Given: class A { String name = "A"; String getName() { return name; } String greeting(){ return "class A"; } } class B extends A { String name = "B"; String greeting() { return "class B"; } } public class Client { public static void main( String[] args ) { A a = new A(); A b = new B(); System.out.println(a.greeting() + "has name" + a.getName()); System.out.println(b.greeting() + "has name" + b.getName()); } }
#415597
65. Replace two of the Modifiers that appear in the Single class to make the code compile. Note: Three modifiers will not be used and four modifiers in the code will remain unchanged. Code public class Single { private static Single instance; public static Single getInstance() { if (instance =
#415598
66. Given: 5. class Thingy{ Meter m = new Meter(); } 6. class Component {void go() { System.out.print("c");}} 7. class Meter extends Component {void go() { System.out.print("m"); }} 8. 9. class DeluxeThingy extends Thingy { 10. public static void main(String[] args) { 11. DeluxeThingy dt = new DeluxeThingy(); 12. dt.m.go(); 13. Thingy t = new DeluxeThingy(); 14. t.m.go(); 15. } 16. } Which two are true? (Choose two.) (A) The output is mm. (B) The output is mc. (C) Component is-a Meter. (D) Component has-a Meter. (E) DeluxeThingy is-a Component. (F) DeluxeThingy has-a Component.
#415599
71. Given: 1. interface A{public void aMethod();} JarB JarD JarE JarA JarC 2. interface B { public void bMethod(); } 3. interface C extends A, B { public void cMethod(); } 4. class D implements B { 5. public void bMethod(){} 6. } 7. class E extends D implements C { 8. public void aMethod(){} 9. public void bMethod(){} 10. public void cMethod(){} 11. } What is the result? (A) Compilation fails because of an error in line 3. (B) Compilation fails because of an error in line 7. (C) Compilation fails because of an error in line 9. (D) If you define D e = new E(), then e.bMethod() invokes the version of bMethod() defined in Line 5. (E) If you define D e = (D)(new E()), then e.bMethod() invokes the version of bMethod() defined in Line 5. (F) If you define D e = (D)(new E()), then e.bMethod() invokes the version of bMethod() defined in Line 9.
#415600
78. 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
#415601
86. Given: 10. abstract class A{ 11. abstract void a1(); 12. void a2(){} 13. } 14. class B extends A{ 15. void a1(){} 16. void a2(){} 17. } 18. class C extends B{void c1(){}} and: A x = new B(); C y = new C(); A z = new C(); What are four valid examples of polymorphic method calls? (Choose four.) (A) x.a2(); (B) z.a2(); (C) z.c1(); (D) z.a1(); (E) y.c1(); (F) x.a1();
#415602
88. Which Three statements are true? (Choose Three.) (A) A final method in class X can be abstract if and only if X is abstract. (B) A protected method in class X can be overridden by any subclass of X. (C) A private static method can be called only within other static methods in class X. (D) A non-static public final method in class X can be overridden in any subclass of X. (E) A public static method in class X can be called by a subclass of X without explicitly referencing the class X. (F) A method with the same signature as a private final method in class X can be implemented in a subclass of X. (G) A protected method in class X can be overridden by a subclass of X only if the subclass is in the same package as X.
#415603
96. Given a class Repetition: 1. package utils; 2. 3. public class Repetition { 4. public static String twice(String s){return s + s;} 5. } and given another class Demo: 1. // insert code here 2. 3. public class Demo { 4. public static void main(String[] args){ 5. System.out.println(twice("pizza")); 6. } 7. } Which code should be inserted at line 1 of Demo.java to compile and run Demo to print "pizzapizza"? (A) import utils.*; (B) static import utils.*; (C) import utils.Repetition.*; (D) static import utils.Repetition.*; (E) import utils.Repetition.twice(); (F) import static utils.Repetition.twice; (G)static import utils.Repetition.twice;
#415604
相關試卷
104年 - SCJP 201-244#99410
104年 · #99410
104年 - SCJP 51-100#99391
104年 · #99391
104年 - SCJP 151-200#99330
104年 · #99330
104年 - SCJP 1-50#41416
104年 · #41416
無年度 - SCJP 6.0 認證教戰手冊第二版 SCJP 6.0 認證教戰手冊第二版 認證教戰手冊第二版_題庫 201-244#83084
#83084
無年度 - SCJP 6.0 認證教戰手冊第二版 SCJP 6.0 認證教戰手冊第二版 認證教戰手冊第二版_題庫 151-200#83081
#83081
無年度 - SCJP 6.0 認證教戰手冊第二版 SCJP 6.0 認證教戰手冊第二版 認證教戰手冊第二版_題庫 101-150#83070
#83070
無年度 - SCJP 6.0 認證教戰手冊第二版 SCJP 6.0 認證教戰手冊第二版 認證教戰手冊第二版_題庫 51-100#83056
#83056