niusouti.com

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 “

题目

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.

相似考题
更多“Class TestException  ”相关问题
  • 第1题:

    Class a = new Class(); Class b = new Class();

    if(a == b) returns true or false, why?


    正确答案:
                   

  • 第2题:

    下面程序输出的结果为( )。 #inClUde”iostream.h” Class A {public: A(){cout<<“CLASS A”<<endl;} ~A()<)}; class B:public A {public: B(){cout<<”CLASSB”<<endl;} ~B(){}}; void main() {A*p; p=new B; B *q; q=new B;}

    A.CLASS A CLASS B

    B.CLASS A CLASS B CLASS B

    C.CLASS A ClASS B

    D.CLASS A CLASS B CLASS A CLASS B CLASS B CLASS B


    正确答案:C
    解析: 本题考查类的继承、类的实例化和构造函数、析构函数的调用方式和何时调用。每实例化一个类就要调用其构造函数,结束运行该实例后调用析构函数。

  • 第3题:

    Which class of Cisco access points operate under IEEE 802.3af power?()

    • A、Class A
    • B、Class 1
    • C、Class 2
    • D、Class 3
    • E、Class 4

    正确答案:D

  • 第4题:

    In which two cases does the compiler supply a default constructor for class A?()  

    • A、 class A{}
    • B、 class A { public A(){} }
    • C、 class A { public A(int x){} }
    • D、 class Z {} class A extends Z { void A(){} }

    正确答案:A,D

  • 第5题:

    在MCDU电子状态页报告里能查看故障()

    • A、Class1&Class3
    • B、Class2&Class3
    • C、Class1&Class2
    • D、Class1,Class2&Class3

    正确答案:D

  • 第6题:

    public class ExceptionTest {   class TestException extends Exception {}   public void runTest () throws TestException {}   public void test () /* Point X*/ {   runTest ();   }   }   At point X on line 4, which code can be added to make the code compile?()  

    • A、 Throws Exception.
    • B、 Catch (Exception e).
    • C、 Throws RuntimeException.
    • D、 Catch (TestException e).
    • E、 No code is necessary.

    正确答案:B

  • 第7题:

    关于嵌套列的用法,错误的是()

    • A、<div class=“row”><br><div class=“col-sm-1”>
    • B、<div class=“col-sm-1”><br><div class=“row”><br> 
    • C、<div class=“row”><br><div class=“container”><br><div class=“col-xs-1”><br> 
    • D、<div class=“container”><br><div class=“row”><br><div class=“col-xs-1”>

    正确答案:C

  • 第8题:

    Which of the following class networks contains 65,534 hosts?()

    • A、Class A
    • B、Class B
    • C、Class C
    • D、Class D

    正确答案:B

  • 第9题:

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


    正确答案: A,C
    解析: 暂无解析

  • 第10题:

    单选题
    研究下面的Java代码:  public class testException{  public static void main(String args[]){       int a[]={0,1,2,3,4};      int sum=0;      try{  for(int i=1;i<6;i++)  sum=sum+a[i];  System.out.println("sum="+sum);                 }      catch(ArrayIndexOutOfBoundsException ){                    System.out.println("数组越界");     }  finally{   System.out.println("程序结束");}  } }  输出结果将是()。
    A

    10  数组越界  程序结束

    B

    10   程序结束

    C

    数组越界  程序结束

    D

    程序结束


    正确答案: B
    解析: 暂无解析

  • 第11题:

    单选题
    What produces a compiler error?()
    A

     class A { public A(int x) {} }

    B

     class A {} class B extends A { B() {} }

    C

     class A { A() {} } class B { public B() {} }

    D

     class Z { public Z(int) {} } class A extends Z {}


    正确答案: A
    解析: 暂无解析

  • 第12题:

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


    正确答案: C
    解析: 暂无解析

  • 第13题:

    下面程序输出的结果为 #include"iostream.h” class A { public: A(){cout<<"CLASSA"<<endl;} ~A() {} }; class B:public A { public: B(){cout<<"CLASS B"<<endl;} ~B(){} }; void main() { A*p; p=new B;

    A.CLASS A CLASS B CLASS B CLASS B

    B.CLASS A CLASS B CLASS A CLASS B

    C.CLASS A CLASS B CLASS B

    D.CLASS A CLASS B


    正确答案:C

  • 第14题:

    对于下面( )类定义,可以通过“newJ_Class()”生成类J_Class的实例对象。

    A、publicclassJ_Class{

    publicJ_Class(void){}

    }

    B、publicclassJ_Class{}

    C、publicclassJ_Class{

    publicJ_Class(Strings){}

    }

    D、publicclassJ_Class{

    publicvoidJ_Class(){}

    publicJ_Class(Strings){}


    正确答案:B

  • 第15题:

    研究下面的Java代码:  public class testException{  public static void main(String args[]){       int a[]={0,1,2,3,4};      int sum=0;      try{  for(int i=1;i<6;i++)  sum=sum+a[i];  System.out.println("sum="+sum);                 }      catch(ArrayIndexOutOfBoundsException ){                    System.out.println("数组越界");     }  finally{   System.out.println("程序结束");}  } }  输出结果将是()。       

    • A、10  数组越界  程序结束
    • B、10   程序结束
    • C、数组越界  程序结束
    • D、程序结束

    正确答案:C

  • 第16题:

    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

  • 第17题:

    1. public class Exception Test {  2. class TestException extends Exception {}  3. public void runTest() throws TestException {}  4. public void test() /* Point X */ {  5. runTest();  6. }  7. }  At Point X on line 4, which code is necessary to make the code compile?()  

    • A、 No code is necessary.
    • B、 throws Exception
    • C、 catch ( Exception e )
    • D、 throws RuntimeException
    • E、 catch ( TestException e)

    正确答案:B

  • 第18题:

    根据栅格系统的标准用法,错误的是()

    • A、<div class="container"><br><div class="row"> 
    • B、<div class="row"><br><div class="col-md-1"> 
    • C、<div class="row"><br><div class="container"> 
    • D、<div class="col-md-1"><br><div class= "row">

    正确答案:C

  • 第19题:

    Which of the following class addresses is reserved for multicast?()

    • A、 Class A
    • B、 Class B
    • C、 Class C
    • D、 Class D

    正确答案:D

  • 第20题:

    What produces a compiler error?()  

    • A、 class A { public A(int x) {} }
    • B、 class A {} class B extends A { B() {} }
    • C、 class A { A() {} } class B { public B() {} }
    • D、 class Z { public Z(int) {} } class A extends Z {}

    正确答案:D

  • 第21题:

    单选题
    public class ExceptionTest {  class TestException extends Exception {}  public void runTest () throws TestException {}  public void test () /* Point X*/  {  runTest ();  }  }   At point X on line 4, which code can be added to make the code compile?()
    A

     Throws Exception.

    B

     Catch (Exception e).

    C

     Throws RuntimeException.

    D

     Catch (TestException e).

    E

     No code is necessary.


    正确答案: E
    解析: 暂无解析

  • 第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.


    正确答案: B
    解析: 暂无解析

  • 第23题:

    单选题
    1. public class Exception Test {  2. class TestException extends Exception {}  3. public void runTest() throws TestException {}  4. public void test() /* Point X */ {  5. runTest();  6. }  7. }  At Point X on line 4, which code is necessary to make the code compile?()
    A

     No code is necessary.

    B

     throws Exception

    C

     catch ( Exception e )

    D

     throws RuntimeException

    E

     catch ( TestException e)


    正确答案: B
    解析: 暂无解析