【系統公告】頁面上方功能列及下方資訊全面更換新版,『舊用戶且擁有VIP』可再切回舊版。 前往查看
阿摩:一個人的成功絕不是個人的努力 而是別人給予的助力
2
(1 分4 秒)
模式:試卷模式
試卷測驗 - SCJP 6.0 認證教戰手冊第二版 SCJP 6.0 認證教戰手冊第二版 認證教戰手冊第二版_題庫 201-244#83084
繼續測驗
再次測驗 下載 下載收錄
1(C).

203 
5e4deea88a64a.jpg
What is the result?
(A) [1, 2, 3, 5]
(B) [2, 1, 3, 5]
(C) [2, 5, 3, 1]
(D) [5, 3, 2, 1]
(E) [1, 3, 5, 2] 
(AB) Compilation fails. 
(AC) An exception is thrown at runtime.


2( ).
X


204 
5e4deeda7a75f.jpg
Which statement is true?
(A) The time to find the value from HashMap with a Person key depends on the size of the map.
(B) Deleting a Person key from a HashMap will delete all map entries for all keys of type Person.
(C) Inserting a second Person object into a HashSet will cause the first Person object to be removed as a duplicate.
(D) The time to determine whether a Person object is contained in a HashSet is constant and does NOT depend on the size of the map.


3( ).
X


205 
5e4deefd5deba.jpg
What is the result?
(A) Compilation fails.
(B) An exception is thrown at runtime.
(C) [608, 610, 612, 629] [608, 610]
(D) [608, 610, 612, 629] [608, 610, 629]
(E) [606, 608, 610, 612, 629] [608, 610] 
(AB) [606, 608, 610, 612, 629] [608, 610, 629]


4( ).
X


206 
5e4def3369e0d.jpg
A programmer iterates over the TreeSet and prints the name of each Drink object. What is the result?
(A) Tea
(B) Coffee
(C) Coffee Tea
(D) Compilation fails.
(E) The code runs with no output. 
(AB) An exception is thrown at runtime.


5( ).
X


207 A programmer must create a generic class MinMax and the type parameter of MinMax must implement Comparable. Which implementation of MinMax will compile? 

(A)  5e4defa85c6a8.jpg

(B)  5e4defc4ae4e9.jpg

(C)  5e4defdb371e5.jpg

(D)  5e4defef30334.jpg


6( ).
X


208 
5e4df016935c9.jpg
Which code, inserted at line 4, guarantees that this program will output [1, 2]?
(A) Set set = new TreeSet();
(B) Set set = new HashSet();
(C) Set set = new SortedSet();
(D) List set = new SortedList();
(E) Set set = new LinkedHashSet();


7( ).
X


209 
5e4df0732ee9a.jpg
Which statement is true about the set variable on line 12?
(A) The set variable contains all six elements from the coll collection, and the order is guaranteed to be preserved.
(B) The set variable contains only three elements from the coll collection, and the order is guaranteed to be preserved.
(C) The set variable contains all six elements from the coll collection, but the order is NOT guaranteed to be preserved.
(D) The set variable contains only three elements from the coll collection, but the order is NOT guaranteed to be preserved.


8( ).
X


210 
5e4df9ffb61a8.jpg
What is the appropriate definition of the hashCode method in class Person?
(A) return super.hashCode();
(B) return name.hashCode() + age * 7;
(C) return name.hashCode() + comment.hashCode() / 2;
(D) return name.hashCode() + comment.hashCode() / 2- age * 3;


9( ).
X


211 
5e4dfddca4458.jpg
A programmer is developing a class Key, that will be used as a key in a standard java.util.HashMap. Which two methods should be overridden to assure that Key works correctly as a key? (Choose two.)
(A) public int hashCode()
(B) public void hashCode()
(C) public int compareTo(Object o)
(D) public boolean equals(Object o)
(E) public boolean compareTo(Key k)


10( ).
X


212 
5e4e03a5c4bf1.jpg
 Which two code fragments, inserted independently at line 5, will compile without warnings? (Choose two.)
(A) public void addStrings(List list){
(B) public void addStrings(List<String> list){
(C) public void addStrings(List<? super String> list){
(D) public void addStrings(List<? extends String> list){


11( ).
X


213 Given a class whose instances, when found in a collection of objects, are sorted by using the compareTo() method, which two statements are true? (choose two.)
(A) The class implements java.lang.Comparable.
(B) The class implements java.util.Comparator.
(C) The interface used to implement sorting allows this class to define only one sort sequence.
(D) The interface used to implement sorting allows this class to define many different sort sequences.


12( ).
X


214 
5e4e09f093ca8.jpg
What is the result?
(A) Compilation fails.
(B) An exception is thrown at runtime.
(C) [608, 610, 612, 629] [608, 610]
(D) [608, 610, 612, 629] [608, 610, 629]
(E) [606, 608, 610, 612, 629] [608, 610] (AB) [606, 608, 610, 612, 629] [608, 610, 629]


13( ).
X


215 
5e4e0a14760fd.jpg
What is the result?
(A) Compilation fails.
(B) aAaA aAa AAaa AaA
(C) AAaa AaA aAa aAaA
(D) AaA AAaa aAaA aAa
(E) aAa AaA aAaA AAaa (AB) An exception is thrown at runtime.


14( ).
X


219 
5e4e0b30c6e3d.jpg
Which two can be results? (Choose two.) 

(A) java.lang.RuntimeException: Problem 

(B) 5e4e0bcbf2e0e.jpg 

(C)  5e4e13f9a4b25.jpg

(D)  5e4e14164d7f1.jpg

(E)  5e4e1426c1cf0.jpg


15( ).
X


220 Which factor or factors 
 1. It is possible for more than two threads to deadlock at once. 
 2. The JVM implementation guarantees that multiple threads cannot enter into a deadlocked state. 
 3. Deadlocked threads release once their sleep() method's sleep duration has expired. 
 4. Deadlocking can occur only when the wait(), notify() and notifyAll() methods are used incorrectly. 
 5. It is possible for a single-threaded application to deadlock if synchronized blocks are used incorrectly. 
 6. If a piece of code is capable of deadlocking, you cannot eliminate the possibility of deadlocking by inserting invocations of Thread.yield().
(A) 16
(B) 25
(C) 34
(D) 12


16( ).
X


221 
5e4e146345c1f.jpg
Which statement is true?
(A) This code can throw an InterruptedException.
(B) This code can throw an IllegalMonitorStateException.
(C) This code can throw a TimeoutException after ten minutes.
(D) Reversing the order of obj.wait() and obj.notify() might cause this method to complete normally.
(E) A call to notify() or notifyAll() from another thread might cause this method to complete normally. 
(AB) This code does NOT compile unless "obj.wait()" is replaced with "((Thread) obj).wait()".


17( ).
X


222 
5e4e148a3af20.jpg
What is the output if the main() method is run?
(A) 4
(B) 5
(C) 8
(D) 9
(E) Compilation fails. 
(AB) An exception is thrown at runtime. 
(AC) It is impossible to determine for certain.


18( ).
X


223 
5e4e14aee78e4.jpg
Which statement is true?
(A) The output could be 5-1 6-1 6-2 5-2
(B) The output could be 6-1 6-2 5-1 5-2
(C) The output could be 6-1 5-2 6-2 5-1
(D) The output could be 6-1 6-2 5-1 7-1


19( ).
X


224 
5e4e14d6c42ce.jpg
What is the result?
(A) Compilation fails.
(B) An exception is thrown at runtime.
(C) The code executes normally and prints "foo";
(D) The code executes normally, but nothing is printed.


20( ).
X


226 Which two statements are true? (Choose two.)
(A) It is possible to synchronize static methods.
(B) When a thread has yielded as a result of yield(), it releases its locks.
(C) When a thread is sleeping as a result of sleep(), it releases its locks.
(D) The Object.wait() method can be invoked only from a synchronized context.
(E) The Thread.sleep() method can be invoked only from a synchronized context. 
(AB) When the thread scheduler receives a notify() request, and notifies a thread, that thread immediately releases its lock.


21( ).
X


227 
5e4e162610590.jpg
What can be a result?
(A) Compilation fails.
(B) An exception is thrown at runtime.
(C) The code executes and prints "StartedComplete".
(D) The code executes and prints "StartedComplete0123".
(E) The code executes and prints "Started0123Complete".


22( ).
X


228 Which three will compile and run without exception? (Choose three.) 
 1. private synchronized Object o; 
 2.  5e4e16993c2f1.jpg
 3. public synchronized void go(){/* code here */} 
 4. private synchronized(this) void go(){/* code here */} 
 5.  5e4e16af1b733.jpg
 6.  5e4e16c3c400e.jpg
(A) 123
(B) 235
(C) 356
(D) 456


23( ).
X


229 
5e4e16fcccfdc.jpg
Which two changes, taken together, would guarantee the output: 1, 2, 3, 4, 5, ? (Choose two.)
(A) move the line 12 print statement into the foo() method
(B) change line 7 to public synchronized void go(){
(C) change the variable declaration on line 2 to private volatile int x;
(D) wrap the code inside the foo() method with a synchronized(this) block
(E) wrap the for loop code inside the go() method with a synchronized block synchronized(this){//for loop code here}


24( ).
X


230 Given that t1 is a reference to a live thread, which is true?
(A) The Thread.sleep() method can take t1 as an argument.
(B) The Object.notify() method can take t1 as an argument.
(C) The Thread.yield() method can take t1 as an argument.
(D) The Thread.setPriority() method can take t1 as an argument.
(E) The Object.notify() method arbitrarily chooses which thread to notify.


25( ).
X


231 
5e4e17220cf0d.jpg
What is the result?
(A) Cat
(B) Dog
(C) Compilation fails.
(D) The code runs with no output.
(E) An exception is thrown at runtime.


26( ).
X


232 
5e4e17381520a.jpg
What is the result?
(A) Compilation fails.
(B) An exception is thrown at runtime.
(C) The code executes normally and prints "bar".
(D) The code executes normally, but nothing prints.


27( ).
X


233 
5e4e1788428ec.jpg
Which two are possible results? (Choose two.)
(A) 0, 2, 4, 4, 6, 8, 10, 6,
(B) 0, 2, 4, 6, 8, 10, 2, 4,
(C) 0, 2, 4, 6, 8, 10, 12, 14,
(D) 0, 0, 2, 2, 4, 4, 6, 6, 8, 8, 10, 10, 12, 12, 14, 14,
(E) 0, 2, 4, 6, 8, 10, 12, 14, 0, 2, 4, 6, 8, 10, 12, 14,


28( ).
X


234 
5e4e17ae849b1.jpg
From another thread, what provides the most reliable way to ensure that foo will stop executing wait()?
(A) foo.notify();
(B) bar.notify();
(C) foo.notifyAll();
(D) Thread.notify();
(E) bar.notifyAll(); 
(AB) Object.notify();


29( ).
X


235 
5e4e182d136f5.jpg
Which two statements are true? (Choose two.)
(A) The output could be 8-1 7-2 8-2 7-1
(B) The output could be 7-1 7-2 8-1 6-1
(C) The output could be 8-1 7-1 7-2 8-2
(D) The output could be 8-1 8-2 7-1 7-2


30( ).
X


236 
5e4e187d3aeca.jpg
What is the result?
(A) The code will deadlock.
(B) The code may run with no output.
(C) An exception is thrown at runtime.
(D) The code may run with output "0 6".
(E) The code may run with output "2 0 6 4". 
(AB) The code may run with output "0 2 4 6".


31( ).
X


238 Which two code fragments will execute the method doStuff() in a separate thread? (Choose two.) 
 1.  5e4e19288ac7e.jpg 
 2.  5e4e1932b2708.jpg
 3  5e4e193d5546f.jpg
 4.  5e4e194c022e3.jpg
 5.  5e4e195aef1c5.jpg
 6.  5e4e196852d4f.jpg
(A) 13
(B) 24
(C) 35
(D) 46


32( ).
X


239 
5e4e19809be88.jpg
What is the result?
(A) Compilation fails.
(B) An exception is thrown at runtime.
(C) The code executes normally and prints "sleep".
(D) The code executes normally, but nothing is printed.


33( ).
X


241 
5e4e19f8e3b1e.jpg
What is the result?
(A) Compilation fails.
(B) An exception is thrown at runtime.
(C) The code executes and prints "running".
(D) The code executes and prints "runningrunning".
(E) The code executes and prints "runningrunningrunning".


34( ).
X


242 
5e4e1a5255a49.jpg
Which three changes should be made to adapt this class to be used safely by multiple threads? (Choose three.)
(A) declare reset() using the synchronized keyword
(B) declare getName() using the synchronized keyword
(C) declare getCount() using the synchronized keyword
(D) declare the constructor using the synchronized keyword
(E) declare increment() using the synchronized keyword


35( ).
X


243 
5e4e1a87d6625.jpg
Which two statements, inserted independently at both lines 35 and 41, tend to allow both threads to temporarily pause and allow the other thread to execute? (Choose two.)
(A) Thread.wait();
(B) Thread.join();
(C) Thread.yield();
(D) Thread.sleep(1);
(E) Thread.notify();


36( ).
X


244 
5e4e1aa032423.jpg
Which statement is true?
(A) Compilation fails.
(B) An exception is thrown at runtime.
(C) Synchronizing the run() method would make the class thread-safe.
(D) The data in variable "x" are protected from concurrent access problems.
(E) Declaring the doThings() method as static would make the class thread-safe. 
(AB) Wrapping the statements within doThings() in a synchronized(new Object()){} block would make the class thread-safe.


【非選題】
201 
5e4dea53a86b4.jpg
Place a result onto each method call to indicate what would happen if the method call were inserted at line 9. Note: Results can be used more than once.
5e4dea8d9f268.jpg



【非選題】
202 
5e4deab072d36.jpg
Place the code into position to create a class that maps from Strings to integer values. The result of execution must be [one]. Some options may be used more than once.
5e4dece61843b.jpg


【非選題】
216 
5e4e0a35eb55d.jpg
Refactor this class to use generics without changing the code's behavior.
5e4e0aa8abc72.jpg


【非選題】
217 Place the code into the GenericB class definition to make the class compile successfully.
5e4e0ad349abb.jpg



【非選題】
218 Place the code elements in position so that the Flags2 class will compile and make appropriate use of the wait/notify mechanism. Note You may reuse code elements.
5e4e0af996168.jpg


【非選題】
225 
5e4e14ffb5085.jpg
Assume that sleep(n) executes in exactly n milliseconds. and all other code executes in an insignificant amount of time.
5e4e1535ab648.jpg


【非選題】
237 Place the code elements into the class so that the code compiles and prints "Run. Run. doIt. " in exactly that order. Note that there may be more than one correct solution.
5e4e18ed8320d.jpg


【非選題】
240 Place a Class on each method that is declared in the class.
5e4e19a095438.jpg


試卷測驗 - SCJP 6.0 認證教戰手冊第二版 SCJP 6.0 認證教戰手冊第二版 認證教戰手冊第二版_題庫 201-244#83084-阿摩線上測驗

李尚傑剛剛做了阿摩測驗,考了2分