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.
F: This code does NOT compile unless "obj.wait()" is replaced with "((Thread) obj).wait()".
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.
F: This code does NOT compile unless "obj.wait()" is replaced with "((Thread) obj).wait()".
举一反三
- Given: 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.
- Which is the correct statement about the throw statement? A: The throw statement allows the code to explicitly throw an exception. B: throw exception expression; It raises an exception which is an arbitrary value. C: throw; can exist in the catch block, as well as in the try and finally blocks. D: throw; can only be used in catch blocks to ignore the exception currently being handled by the catch block.
- Which of the following statements is true? ( ) A: The catch block contains the code that might throw an exception. B: The try block contains the code that handles the exception if one occurs. C: You can have many catch blocks to handle different types of exceptions. D: When a try block terminates, any variables declared in the try block are preserved.
- Don't wait for me. I _________ a few minutes late.( ) A: might be B: can have been or C: might have been D: can be
- Given this method in a class: public String toString() { StringBuffer buffer = new StringBuffer(); buffer.append(‟ buffer.append(this.name); buffer.append(‟>‟); return buffer.toString(); } Which is true?() A: This code is NOT thread-safe. B: The programmer can replace StringBuffer with StringBuilder with no other changes. C: This code will perform well and converting the code to use StringBuilder will not enhance the performance. D: This code will perform poorly. For better performance, the code should be rewritten: return “”;