阿摩線上測驗
登入
首頁
>
OJCP(SCJP)
> 無年度 - SCJP 6.0 認證教戰手冊第二版 SCJP 6.0 認證教戰手冊第二版 認證教戰手冊第二版_題庫 51-100#83056
無年度 - SCJP 6.0 認證教戰手冊第二版 SCJP 6.0 認證教戰手冊第二版 認證教戰手冊第二版_題庫 51-100#83056
科目:
OJCP(SCJP) |
選擇題數:
46 |
申論題數:
4
試卷資訊
所屬科目:
OJCP(SCJP)
選擇題 (46)
51
Which statement is true about the classes and interfaces? (A) Compilation will succeed for all classes and interfaces. (B) Compilation of class C will fail because of an error in line 2. (C) Compilation of class C will fail because of an error in line 6. (D) Compilation of class AImpl will fail because of an error in line 2.
54
What can directly access and change the value of the variable name?(A) any class (B) only the Target class (C) any class in the test package (D) any class that extends Target
55
What is the result?(A) 0, 0, 0 (B) 150, 60, 0 (C) Compilation fails. (D) 150, 150, 150 (E) An exception is thrown at runtime.
56
Which is true?(A) if line 10 is removed, the compilation succeeds. (B) if line 11 is removed, the compilation succeeds. (C) if line 12 is removed, the compilation succeeds. (D) if line 13 is removed, the compilation succeeds. (E) More than one line must be removed for compilation to succeed.
57
What is the result? (A) Canada (B) null Canada (C) Canada null (D) Canada Canada (E) Compilation fails due to an error on line 26.
(AB) Compilation fails due to an error on line 29.
58
Which code, inserted at line 16, will cause a java.lang.ClassCastException? (A) Alpha a = x; (B) Foo f = (Delta)x; (C) Foo f = (Alpha)x; (D) Beta b = (Beta)(Alpha)x;
59
Assume the current directory is bigProject, what it the result? (A) If the compile is successful, Utils.class is added to the source directory. (B) The compiler returns an invalid flag error. (C) If the compile is successful, Utils.class is added to the classes directory. (D) If the compile is successful, Utils.class is added to the bigProject directory.
複選題
60
And MainClass exists in the /apps/com/company/application directory. Assume the CLASSPATH environment variable is set to "." (current directory).
Which two java commands entered at the command line will run MainClass? (Choose two.) (A) java MainClass if run from the /apps directory (B) java com.company.application.MainClass if run from the /apps directory (C) java -classpath /apps com.company.application.MainClass if run from any directory (D) java-classpath . MainClass if run from the /apps/com/company/application directory (E) java -classpath /apps/com/company/application:. MainClass if run from the /apps directory
(AB) java com.company.application.MainClass if run from the /apps/com/company/application directory
61
If both classes are in the correct directories for their packages, and the Mammal class correctly defines the findSalmon() method, which change allows this code to compile? (A) add import animals. mammals.*; at line 2 in Salmon.java (B) add import animals.fish.*; at line 2 in GrizzlyBearjava (C) add import animals.fish.Salmon.*; at line 2 in GrizzlyBear.java (D) add import animals. mammals.GrizzlyBear*; at line 2 in Salmon.java
62
What is the result? (A) b 3 (B) b 8 (C) b 13 (D) f 3 (E) f 8
(AB) f 13
(AC) Compilation fails,
(AD) An exception is thrown at runtime.
63
Which three are valid? (Choose three.)
1. p0 = p1;
2. p1 = p2,
3. p2 = p4;
4. p2 = (ClassC)p1;
5. p1 = (ClassB)p3;
6. p2 = (ClassC)p4; (A) 123 (B) 126 (C) 235 (D) 156
66
Which two are true? (Choose two.)
1. The output is mm.
2. The output is mc.
3. Component is-a Meter.
4. Component has-a Meter.
5. DeluxeThingy is-a Component.
6. DeluxeThingy has-a Component. (A) 16 (B) 34 (C) 12 (D) 56
複選題
67
Which two methods, inserted independently at line 17, correctly complete the Sales class? (Choose two.) (A) double getSalesAmount() { return 1230.45; } (B) public double getSalesAmount() { return 1230.45; } (C) private double getSalesAmount() { return 1230.45; } (D) protected double getSalesAmount() { return 1230.45; }
68
How many of these method names follow JavaBean Listener naming rules? (A) 1 (B) 2 (C) 3 (D) 4 (E) 5
複選題
69
Which three are valid on line 12? (Choose three.) (A) final (B) static (C) native (D) public (E) private
(AB) abstract
(AC) protected
70
Given the fully-qualified class names:
com.foo.bar.Dog
com.foo.bar.blatz.Book
com.bar.Car
com.bar.blatz.Sun
Which graph represents the correct directory structure for a JAR file from which those classes can be used by the compiler and JVM? (A) Jar A (B) Jar B (C) Jar C (D) Jar D (E) Jar E
複選題
71
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.
(AB) If you define D e = D(new E()), then e.bMethod() invokes the version of bMethod() defined in Line 9.
72
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.
73
Which class correctly uses the Data interface and Info class?
(A)
(B)
(C)
(D)
(E)
(AB)
複選題
74 Which two classes correctly implement both the java.lang.Runnable and the java.lang.Cloneable interfaces? (Choose two.)
(A)
(B)
(C)
(D)
(E)
75
What is the result? (A) Compilation succeeds. (B) Exactly one class does NOT compile. (C) Exactly two classes do NOT compile. (D) Exactly four classes do NOT compile. (E) Exactly three classes do NOT compile.
76
What is the result? (A) TestA (B) TestB (C) Compilation fails. (D) An exception is thrown at runtime.
77
What is the result? (A) 1 2 3 (B) Compilation fails because of an error in line 12. (C) Compilation fails because of an error in line 13. (D) Compilation fails because of an error in line 14. (E) A ClassCastException is thrown at runtime.
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.)
1. The JAR file is located at $JAVA_HOME/jre/classes/myLib.jar.
2. The JAR file is located at $JAVA_HOME/jre/lib/ext/myLib.jar.
3. The JAR file is located at /foo/myLib.jar and a classpath environment variable is set that includes /foo/myLib.jar/Paper.class.
4. The JAR file is located at /foo/myLib.jar and a classpath environment variable is set that includes /foo/myLib.jar.
5. The JAR file is located at /foo/myLib.jar and the Book class is compiled using javac -cp /foo/myLib.jar/Paper Book.java
6. The JAR file is located at /foo/myLib.jar and the Book class is compiled using javac -d /foo/myLib.jar Book.java 7. The JAR file is located at foo/myLib.jar and the Book class is compiled using javac -classpath /foo/myLib.jar Book.java (A) 123 (B) 247 (C) 567 (D) 147
79
What is the result of executing XMLMessage.main? (A) text (B) Compilation fails. (C) <msg>text</msg> (D) An exception is thrown at runtime.
80
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.
(AB) An exception is thrown at runtime.
81
What is the result? (A) The file will compile without error. (B) Compilation fails. Only line 7 contains an error. (C) Compilation fails. Only line 12 contains an error. (D) Compilation fails. Only line 13 contains an error. (E) Compilation fails. Only lines 7 and 12 contain errors.
(AB) Compilation fails. Only lines 7 and 13 contain errors.
(AC) Compilation fails. Lines 7, 12, and 13 contain errors.
82
What is the result? (A) Compilation succeeds. (B) Compilation fails due to multiple errors. (C) Compilation fails due to an error only on line 20. (D) Compilation fails due to an error only on line 21. (E) Compilation fails due to an error only on line 22.
(AB) Compilation fails due to an error only on line 12.
83
Which three statements are true? (Choose three.)
1. Compilation fails.
2. The code compiles and the output is 2.
3. If lines 16, 17 and 18 were removed, compilation would fail.
4. If lines 24, 25 and 26 were removed, compilation would fail.
5. If lines 16, 17 and 18 were removed, the code would compile and the output would be 2.
6. If lines 24, 25 and 26 were removed, the code would compile and the output would be 1. (A) 256 (B) 146 (C) 356 (D) 123
84
What is the result? (A) Afoo Afoo (B) Afoo Bfoo (C) Bfoo Afoo (D) Bfoo Bfoo (E) Compilation fails.
(AB) An exception is thrown at runtime.
85
What is the result? (A) peep (B) bark (C) meow (D) Compilation fails. (E) An exception is thrown at runtime.
86
What are four valid examples of polymorphic method calls? (Choose four.)
1. x.a2();
2. z.a2();
3. z.c1();
4. z.a1();
5. y.c1();
6. x.a1(); (A) 1246 (B) 123456 (C) 2345 (D) 13465
87 A team of programmers is involved in reviewing a proposed design for a new utility class, After some discussion, they realize that the current design allows other classes to access methods in the utility class that should be accessible only to methods within the utility class itself. What design issue has the team discovered? (A) Tight coupling (B) Low cohesion (C) High cohesion (D) Loose coupling (E) Weak encapsulation (AB) Strong encapsulation
88 Which Three statements are true? (Choose Three.)
1. A final method in class X can be abstract if and only if X is abstract.
2. A protected method in class X can be overridden by any subclass of X.
3. A private static method can be called only within other static methods in class X.
4. A non-static public final method in class X can be overridden in any subclass of X.
5. A public static method in class X can be called by a subclass of X without explicitly referencing the class X.
6. A method with the same signature as a private final method in class X can be implemented in a subclass of X.
7. 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. (A) 123 (B) 456 (C) 256 (D) 1256
複選題
89
What two must the programmer do to correct the compilation errors? (Choose two.) (A) insert a call to this() in the Car constructor (B) insert a call to this() in the MeGo constructor (C) insert a call to super() in the MeGo constructor (D) insert a call to super(vin) in the MeGo constructor (E) change the wheelCount variable in Car to protected
(AB) change line 3 in the MeGo class to super.wheelCount = 3;
90
What is the result? (A) s 14 (B) s 16 (C) s 10 (D) Compilation fails. (E) An exception is thrown at runtime.
91 A class games.cards.Poker is correctly defined in the jar file Poker.jar. A user wants to execute the main method of Poker on a UNIX system using the command:
java games.cards.Poker
What allows the user to do this? (A) put Poker.jar in directory /stuff/java, and set the CLASSPATH to include /stuff/java (B) put Poker.jar in directory /stuff/java, and set the CLASSPATH to include /stuff/java/*.jar (C) Put Poker.jar in directory /stuff/java, and set the CLASSPATH to include /stuff/java/Poker.jar (D) put Poker.jar in directory /stuff/java/games/cards, and set the CLASSPATH to include /stuff/java (E) put Poker.jar in directory /stuff/java/games/cards, and set the CLASSPATH to include /stuff/java/*.jar
(AB) put Poker.jar in directory /stuff/java/games/cards, and set the CLASSPATH to include /stuff/java/Poker.jar
92
Which command line correctly runs Commander? (A) java Commander (B) java com.sun.sjcp.Commander (C) java com/sun/sjcp/Commander (D) java -cp com.sun.sjcp Commander (E) java -cp com/sun/sjcp Commander
93
Which code, inserted at line 14, allows the Sprite class to compile? (A) Direction d = NORTH; (B) Nav.Direction d = NORTH; (C) Direction d = Direction.NORTH; (D) Nav.Direction d = Nav.Direction.NORTH;
94
Which code fragment inserted at line 19, allows the Rainbow class to compile? (A) MyColor skyColor = BLUE; (B) MyColor treeColor = MyColor.GREEN; (C) if(REDgetRGB() < BLUEgetRGB()){} (D) Compilation fails due to other error(s) in the code. (E) MyColor purple = new MyColor(0xff00ff);
(AB) MyColor purple = MyColor.BLUE + MyColor.RED;
95
What is the result? (A) test (B) null (C) An exception is thrown at runtime. (D) Compilation fails because of an error in line 1. (E) Compilation fails because of an error in line 4.
(AB) Compilation fails because of an error in line 5.
複選題
96
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();
(AB) import static utils.Repetition.twice;
(AC) static import utils.Repetition.twice;
97 Which statement is true? (A) A class's finalize() method CANNOT be invoked explicitly. (B) super.finalize() is called implicitly by any overriding finalize() method. (C) The finalize() method for a given object is called no more than once by the garbage collector. (D) The order in which finalize() is called on two objects is based on the order in which the two objects became finalizable.
98
What is the result? (A) No output is produced. 1 2 3 (B) No output is produced. 2 3 4 (C) No output is produced. 1 2 3 4 (D) An exception is thrown at runtime. 1 2 3 (E) An exception is thrown at runtime. 2 3 4
(AB) An exception is thrown at runtime. 1 2 3 4
99
When line 14 is reached, how many objects are eligible for the garbage collector? (A) 0 (B) 1 (C) 2 (D) 3 (E) 4
(AB) 6
100
What is the result?
(A) 12 (B) The code runs with no output. (C) An exception is thrown at runtime. (D) Compilation fails because of an error in line 21. (E) Compilation fails because of an error in line 22.
(AB) Compilation fails because of an error in line 31.
申論題 (4)
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.
64
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.
相關試卷
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