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

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


参考解析

解析: 暂无解析

相关考题:

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:What is the result when method testIfA is invoked?() A.TrueB.Not trueC.An exception is thrown at runtime.D.Compilation fails because of an error at line 12.E.Compilation fails because of an error at line 19.

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.

Click the Exhibit button.Given:What is the result?() A.Line 26 prints a to System.out.B.Line 26 prints b to System.out.C.An exception is thrown at line 26 at runtime.D.Compilation of class A will fail due to an error in line 6.

Click the Exhibit button. What is the output if the main() method is run?() A.4B.5C.8D.9E.Compilation fails.F.An exception is thrown at runtime.G.It is impossible to determine for certain.

Click the Exhibit button. Given:Which two statements are true if a NullPointerException is thrown on line 3 of class C? () A.The application will crash.B.The code on line 29 will be executed.C.The code on line 5 of class A will execute.D.The code on line 5 of class B will execute.E.The exception will be propagated back to line 27.

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.

1.class TestSuper { 22.TestSuper(int i) { } 3. } 4.class TestSub extends TestSuper{ } 5.class TestAll { 6.public static void main (String [] args) { 7.new TestSub(); 8.} 9.} Which is true?()  A、 Compilation fails.B、 The code runs without exception.C、 An exception is thrown at line 7.D、 An exception is thrown at line 2.

1. public class A {  2. void A() {  3. System.out.println(“Class A”);  4. }  5. public static void main(String[] args) {  6. new A();  7. }  8. }  What is the result?()  A、 Class AB、 Compilation fails.C、 An exception is thrown at line 2.D、 An exception is thrown at line 6.E、 The code executes with no output.

1. public class A {  2. public void method1() {  3. B b=new B();  4. b.method2();  5. // more code here  6. }  7. }  1. public class B {  2. public void method2() {  3.C c=new C();  4. c.method3();  5. // more code here  6. }  7. }  1. public class C {  2. public void method3() {  3. // more code here  4. }  5. }  Given:  25. try {  26. A a=new A();  27. a.method1();  28. } catch (Exception e) {  29. System.out.print(”an error occurred”);  30. }  Which two are true if a NullPointerException is thrown on line 3 of class C?()A、 The application will crash.B、 The code on line 29 will be executed.C、 The code on line 5 of class A will execute.D、 The code on line 5 of class B will execute.E、 The exception will be propagated back to line 27.

Which statement is true?()A、A class’s finalize() method CANNOT be invoked explicitly.B、super.finalize() is called implicitly by any overriding finalize() method.C、The finalize() method for a given object is called no more than once by the garbage collector.D、The order in which finalize() is called on two objects is based on the order in which the two objects became finalizable.

Which two statements are true about the hashCode method?()A、The hashCode method for a given class can be used to test for object equality and object inequality for that class.B、The hashCode method is used by the java.util.SortedSet collection class to order the elements within that set.C、The hashCode method for a given class can be used to test for object inequality, but NOT objecte quality, for that class.D、The only important characteristic of the values returned by a hashCode method is that the distribution of values must follow a Gaussian distribution.E、The hashCode method is used by the java.util.HashSet collection class to group the elements within that set into hash buckets for swift retrieval.

单选题1.class TestSuper { 22.TestSuper(int i) { } 3. } 4.class TestSub extends TestSuper{ } 5.class TestAll { 6.public static void main (String [] args) { 7.new TestSub(); 8.} 9.} Which is true?()A Compilation fails.B The code runs without exception.C An exception is thrown at line 7.D An exception is thrown at line 2.

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

单选题Which statement is true?()AA class’s finalize() method CANNOT be invoked explicitly.Bsuper.finalize() is called implicitly by any overriding finalize() method.CThe finalize() method for a given object is called no more than once by the garbage collector.DThe order in which finalize() is called on two objects is based on the order in which the two objects became finalizable.

单选题You are working on a debug build of an application.You need to find the line of code that caused an exception to be thrown. Which property of the Exception class should you use to achieve this goal?()ADataBMessageCStack TraceDSource

单选题Click the Exhibit button. What is the result?()A Line 26 prints "a" to System.out.B Line 26 prints "b" to System.out.C An exception is thrown at line 26 at runtime.D Compilation of class A will fail due to an error in line 6.

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

多选题1. public class A {  2. public void method1() {  3. B b=new B();  4. b.method2();  5. // more code here  6. }  7. }  1. public class B {  2. public void method2() {  3.C c=new C();  4. c.method3();  5. // more code here  6. }  7. }  1. public class C {  2. public void method3() {  3. // more code here  4. }  5. }  Given:  25. try {  26. A a=new A();  27. a.method1();  28. } catch (Exception e) {  29. System.out.print(”an error occurred”);  30. }  Which two are true if a NullPointerException is thrown on line 3 of class C?()AThe application will crash.BThe code on line 29 will be executed.CThe code on line 5 of class A will execute.DThe code on line 5 of class B will execute.EThe exception will be propagated back to line 27.

多选题Which two statements are true about the hashCode method?()AThe hashCode method for a given class can be used to test for object equality and object inequality for that class.BThe hashCode method is used by the java.util.SortedSet collection class to order the elements within that set.CThe hashCode method for a given class can be used to test for object inequality, but NOT objecte quality, for that class.DThe only important characteristic of the values returned by a hashCode method is that the distribution of values must follow a Gaussian distribution.EThe hashCode method is used by the java.util.HashSet collection class to group the elements within that set into hash buckets for swift retrieval.

单选题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. Given: Which two statements are true if a NullPointerException is thrown on line 3 of class C? ()AThe application will crash.BThe code on line 29 will be executed.CThe code on line 5 of class A will execute.DThe code on line 5 of class B will execute.EThe exception will be propagated back to line 27.

单选题Given: What is the result when method testIfA is invoked?()A TrueB Not trueC An exception is thrown at runtime.D Compilation fails because of an error at line 12.E Compilation fails because of an error at line 19.

单选题1. public class A {  2. void A() {  3. System.out.println(“Class A”);  4. }  5. public static void main(String[] args) {  6. new A();  7. }  8. }  What is the result?()A Class AB Compilation fails.C An exception is thrown at line 2.D An exception is thrown at line 6.E The code executes with no output.

单选题Click the Exhibit button. What is the output if the main( ) method is run?()A 4B 5C 8D 9E Compilation fails.F An exception is thrown at runtime.G It is impossible to determine for certain.