Oracle Java Certified Programmer 認定 1Z0-501 試験問題:
1. Given:
1 . public class SyncTest {
2 . private int x;
3 . private int y;
4 . public synchronized void setX (int i) (x=1;)
5 . public synchronized void setY (int i) (y=1;)
6 . public synchronized void setXY(int 1)(set X(i); setY(i);)
7 . public synchronized Boolean check() (return x !=y;)
8 . )
Under which conditions will check () return true when called from a different class?
A) Check() can only return true if SyncTest is changed to allow x and y to be set separately.
B) Check() can never return true.
C) Check() can return true when setXY is called by multiple threads.
D) Check() can return true when multiple threads call setX and setY separately.
2. Which statement about static inner classes is true?
A) A static inner class does not require an instance of the enclosing class.
B) Instance members of a static inner class can be referenced using the class name of the static innerclass.
C) A static inner class cannot be a static member of the outer class.
D) An anonymous class can be declared as static.
3. Which two interfaces provide the capability to store objects using a key-value pair?
(Choose Two)
A) Java.util.StoredSet.
B) Java.util.List.
C) Java.util.Set.
D) Java.util.Collection.
E) Java.util.Map.
F) Java.util.StoredMap.
4. Given:
1 . public class IfTest (
2 . public static void main(string[]args) {
3 . int x = 3;
4 . int y = 1;
5 . if (x = y)
6 . system.out.printIn("Not equal");
7 . else
8 . system.out.printIn("Equal");
9 .}
1 0. )
What is the result?
A) An error at line 5 causes compilation to fall.
B) The output in "Not Equal"
C) The program executes but does not print a message.
D) The output is "Equal"
5. Given:
1 . public class Test {
2 . public static void main (String args[]) {
3 .class Foo {
4 .public int i = 3;
5 .}
6 .Object o = (Object) new Foo();
7 .Foo foo = (Foo)o;
8 .System.out.printIn(foo. i);
9 .}
1 0. }
What is the result?
A) Compilation will succeed and the program will print "3"
B) Compilation will fail.
C) Compilation will succeed but the program will throw a ClassCastException at line 7.
D) Compilation will succeed but the program will throw a ClassCastException at line 6.
質問と回答:
質問 # 1 正解: B | 質問 # 2 正解: A | 質問 # 3 正解: E、F | 質問 # 4 正解: A | 質問 # 5 正解: A |