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?()
第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
第3题:
Which class of Cisco access points operate under IEEE 802.3af power?()
第4题:
In which two cases does the compiler supply a default constructor for class A?()
第5题:
在MCDU电子状态页报告里能查看故障()
第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?()
第7题:
关于嵌套列的用法,错误的是()
第8题:
Which of the following class networks contains 65,534 hosts?()
第9题:
Class a will not compile.
Line 46 can throw the unchecked exception TestException.
Line 45 can throw the unchecked exception TestException.
Line 46 will compile if the enclosing method throws a TestException.
Line 46 will compile if enclosed in a try block, where TestException is caught.
第10题:
10 数组越界 程序结束
10 程序结束
数组越界 程序结束
程序结束
第11题:
class A { public A(int x) {} }
class A {} class B extends A { B() {} }
class A { A() {} } class B { public B() {} }
class Z { public Z(int) {} } class A extends Z {}
第12题:
Compilation succeeds.
Class A does not compile.
The method declared on line 9 cannot be modified to throw TestException.
TestA compiles if line 10 is enclosed in a try/catch block that catches TestException.
第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
第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){}
第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("程序结束");} } } 输出结果将是()。
第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?()
第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?()
第18题:
根据栅格系统的标准用法,错误的是()
第19题:
Which of the following class addresses is reserved for multicast?()
第20题:
What produces a compiler error?()
第21题:
Throws Exception.
Catch (Exception e).
Throws RuntimeException.
Catch (TestException e).
No code is necessary.
第22题:
Line 33 must be called within a try block.
The exception thrown by method1 in class a is not required to be caught.
The method declared on line 31 must be declared to throw a RuntimeException.
On line 5 of class a, the call to method2 of class b does not need to be placed in a try/catch block.
第23题:
No code is necessary.
throws Exception
catch ( Exception e )
throws RuntimeException
catch ( TestException e)