单选题Given: 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 a try/catch block that catches TestException.

题目
单选题
Given: 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 a try/catch block that catches TestException.

如果没有搜索结果或未解决您的问题,请直接 联系老师 获取答案。
相似问题和答案

第1题:

Given: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.


参考答案:C

第2题:

Given:When the doSomething method is called, after which line does the Object created in line 5 become available for garbage collection?()

A.Line 5

B.Line 6

C.Line 7

D.Line 8

E.Line 9

F.Line 10


参考答案:D

第3题:

Given: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 a try/catch block that catches TestException.


参考答案:D

第4题:

You are creating a Windows Communication Foundation (WCF) service that is implemented as follows. (Line numbers are included for reference only.) 01 [ServiceContract] 02 [ServiceBehavior(IncludeExceptionDetailsInFaults = true)] 03 public class OrderService 04 { 05 [OperationContract] 06 public void SubmitOrder(Order anOrder) 07 { 08 try 09 { 10 ... 11 } 12 catch(DivideByZeroException ex) 13 { 14 ... 15 } 16 } 17 } You need to ensure that the stack trace details of the exception are not included in the error information sent to the client. What should you do?()

  • A、Replace line 14 with the following line: throw;
  • B、Replace line 14 with the following line: throw new FaultException(anOrder, ex.ToString());
  • C、After line 05, add the following line: [FaultContract(typeof(FaultException))] Replace line 14 with the following line: throw ex;
  • D、Alter line 05, add the following line: [FaultContract(typeof(FaultException))] Replace line 14 with the following line: throw new FaultException(anOrder, "Divide by zero exception");

正确答案:D

第5题:

Class TestException  1. public class TestException extends Exception {  2. } Class a:  1. public class a {  2.  3. public String sayHello(String name) throws TestException {  4.  5. if(name == null) {  6. throw new TestException();  7. }  8.  9. return “Hello “+ name;  10. }  11.  12. }  A programmer wants to use this code in an application: 45. A a=new A();  46. System.out.println(a.sayHello(”John”));  Which two are true?()

  • A、 Class a will not compile.
  • B、 Line 46 can throw the unchecked exception TestException.
  • C、 Line 45 can throw the unchecked exception TestException.
  • D、 Line 46 will compile if the enclosing method throws a TestException.
  • E、 Line 46 will compile if enclosed in a try block, where TestException is caught.

正确答案:D,E

第6题:

Click the Exhibit button. Given:Which statement is true if a TestException is thrown on line 3 of class B? ()

A.Line 33 must be called within a try block.

B.The exception thrown by method1 in class A is not required to be caught.

C.The method declared on line 31 must be declared to throw a RuntimeException.

D.On line 5 of class A, the call to method2 of class B does not need to be placed in a try/catch block.


参考答案:B

第7题:

Which the statement is true?()

  • A、 The Error class is a Runtime Exception.
  • B、 No exceptions are subclasses of Error.
  • C、 Any statement that may throw an Error must be enclosed in a try block.
  • D、 any statement that may throw an Exception must be enclosed in a try block.
  • E、 Any statement that may throw an Runtime Exception must be enclosed in a try block.

正确答案:B

第8题:

Click the Exhibit button. Which statement is true about the classes and interfaces in the exhibit?()

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


参考答案:C

第9题:

1. public class a {  2. public void method1() {  3. try {  4. B b=new b();  5. b.method2();  6. // more code here  7. } catch (TestException te) {  8. throw new RuntimeException(te);  9. }  10. }  11. }  1. public class b {  2. public void method2() throws TestException {  3. // more code here  4. }  5. }  1. public class TestException extends Exception {  2. }  Given:  31. public void method() {  32. A a=new a();  33. a.method1();  34. }  Which is true if a TestException is thrown on line 3 of class b?()

  • A、 Line 33 must be called within a try block.
  • B、 The exception thrown by method1 in class a is not required to be caught.
  • C、 The method declared on line 31 must be declared to throw a RuntimeException.
  • D、 On line 5 of class a, the call to method2 of class b does not need to be placed in a try/catch block.

正确答案:B

第10题:

What is wrong with the following code?()   class MyException extends Exception {}   public class Qb4ab {   public void foo() {  try {  bar();  } finally {  baz();   } catch (MyException e) {}  }   public void bar() throws MyException {   throw new MyException();  }   public void baz() throws RuntimeException {   throw new RuntimeException();   }   }  

  • A、Since the method foo() does not catch the exception generated by the method baz(), it must      declare the RuntimeException in its throws clause.
  • B、A try block cannot be followed by both a catch and a finally block.
  • C、An empty catch block is not allowed.
  • D、A catch block cannot follow a finally block.
  • E、A finally block must always follow one or more catch blocks.

正确答案:D

更多相关问题