Which statement is true?()
A: Compilation succeeds.
B: class A does not compile.
C: The method declared on line 9 cannot be modified to throw TestException.
D: TestA compiles if line 10 is enclosed in try/catch block that catches TestException.
A: Compilation succeeds.
B: class A does not compile.
C: The method declared on line 9 cannot be modified to throw TestException.
D: TestA compiles if line 10 is enclosed in try/catch block that catches TestException.
举一反三
- 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.
- Given: Which statement is true?() A: The equals method does NOT properly override the Object.equals method. B: Compilation fails because the private attribute p.name cannot be accessed in line 5. C: To work correctly with hash-based data structures,this class must also implement the hashCodemethod. D: When adding Person objects to a java.util.Set collection,the equals method in line 4 will preventduplicates.
- 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.
- 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 will not compile A: if(true); B: if(true) {} C: if(true) {;} D: if(true) {;;} E: if(true); {}; F: All statements will compile.