网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)
单选题
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.” 相关考题
考题 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.

考题 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

考题 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.

考题 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.

考题 Given:When the doSomething method is called, after which line does the Object created in line 5 become available for garbage collection?() A.Line 5B.Line 6C.Line 7D.Line 8E.Line 9F.Line 10

考题 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.

考题 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.

考题 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.

考题 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");

考题 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.

考题 Given the following code fragment:     public void create() {     Vector myVect;     myVect = new Vector();      }  Which of the following statements are true?() A、 The declaration on line 2 does not allocate memory space for the variable myVect.B、 The declaration on line 2 allocates memory space for a reference to a Vector object.C、 The statement on line 2 creates an object of class Vector.D、 The statement on line 3 creates an object of class Vector.E、 The statement on line 3 allocates memory space for an object of class Vector.

考题 public class X {  public static void main (String[] args)  {  byte b = 127;  byte c = 126;  byte d = b + c;  }  }   Which statement is true?()  A、 Compilation succeeds and d takes the value 253.B、 Line 5 contains an error that prevents compilation.C、 Line 5 throws an exception indicating “Out of range”D、 Line 3 and 4 contain error that prevent compilation.E、 The compilation succeeds and d takes the value of 1.

考题 interface foo {   int k = 0;   }    public class test implements Foo (   public static void main(String args) (    int i;   Test test = new test ();   i= test.k;   i= Test.k;   i= Foo.k;   )   )   What is the result? ()A、 Compilation succeeds.B、 An error at line 2 causes compilation to fail.C、 An error at line 9 causes compilation to fail.D、 An error at line 10 causes compilation to fail.E、 An error at line 11 causes compilation to fail.

考题 1. class Exc0 extends Exception { }  2. class Exc1 extends Exc0 { }  3. public class Test {  4. public static void main(String args[]) {  5. try {  6. throw new Exc1();  7. } catch (Exc0 e0) {  8. System.out.println(“Ex0 caught”);  9. } catch (Exception e) {  10. System.out.println(“exception caught”);  11. }  12. }  13. }  What is the result?()  A、 Ex0 caughtB、 exception caughtC、 Compilation fails because of an error at line 2.D、 Compilation fails because of an error at line 6.

考题 单选题interface foo {   int k = 0;   }    public class test implements Foo (   public static void main(String args) (    int i;   Test test = new test ();   i= test.k;   i= Test.k;   i= Foo.k;   )   )   What is the result? ()A  Compilation succeeds.B  An error at line 2 causes compilation to fail.C  An error at line 9 causes compilation to fail.D  An error at line 10 causes compilation to fail.E  An error at line 11 causes compilation to fail.

考题 单选题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.

考题 单选题Given: What is the result?()A Compilation succeeds.B Compilation fails due to multiple errors.C Compilation fails due to an error only on line 20.D Compilation fails due to an error only on line 21.E Compilation fails due to an error only on line 22.

考题 单选题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.

考题 单选题Given: When the doSomething method is called, after which line does the Object created in line 5 become available for garbage collection?()A Line 5B Line 6C Line 7D Line 8E Line 9F Line 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.

考题 多选题Given the following code fragment:     public void create() {     Vector myVect;     myVect = new Vector();      }  Which of the following statements are true?()AThe declaration on line 2 does not allocate memory space for the variable myVect.BThe declaration on line 2 allocates memory space for a reference to a Vector object.CThe statement on line 2 creates an object of class Vector.DThe statement on line 3 creates an object of class Vector.EThe statement on line 3 allocates memory space for an object of class Vector.

考题 单选题public class X {   public static void main (String args) {   byte b = 127;   byte c = 126;   byte d = b + c;   }   }   Which statement is true?()A  Compilation succeeds and d takes the value 253.B  Line 5 contains an error that prevents compilation.C  Line 5 throws an exception indicating “Out of range”D  Line 3 and 4 contain error that prevent compilation.E  The compilation succeeds and d takes the value of 1.

考题 单选题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);

考题 单选题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 method 1 in class A is not required to be caught.C The method declared on line 31 must be declared to throw a runtime exception.D On line 5 of class A,the call to method 2 of class B does not need to be placed in a try catch block.

考题 单选题1. public class Person {  2. private String name;  3. public Person(String name) { this.name = name; }  4. public boolean equals(Person p) {  5. return p.name.equals(this.name);  6. }  7. }  Which 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 hashCode method.D  When adding Person objects to a java.util.Set collection, the equals method in line 4 will prevent duplicates.

考题 单选题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.

考题 单选题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.