首页/ 题库 / [多选题]Class TestException 的答案

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?()

多选题
2022-06-18 15:31
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

试题解析

标签: CMS专题
感兴趣题目
有如下程序: #include <iostream.h> class x { protected: int a; public: x() { a=1; } }; class x1 : virtual public x { public: x1() { a+=1; cout<<a; } }; class x2 : virtual public x { public: x2() { a+=2; cout<<a; } }; class y : public xl,public x2 { public: y() { cout<<a<<end1; } }; int main() { y obj; return O; } 该程序运行后的输出结果是( )。
下面程序段的输出结果为 package test; public class Class A { int x=20; static int y=6; public static void main(String args[]) { Class B b=new Class B(); b.go(10); System.out.println("x"+b.x); } } class ClassB { int x; void go(int y) { ClassA a=new ClassA(); x=a.y; } }
下面程序的运行结果是 #include<iostream.h> class base{ protected: int a; public: base(){cout <<"0";} }; class basel:virtual base{ public: basel () {cout <<"1";} }; class base2:virtual base{ public: base2(){cout <<"2";} }; class derived:public basel,public base2{ public: derived(){cout <<"3";} }; void main() { derived obj; cout <<end1; }
下列程序的输出结果是 class Demo { void test( ) { Systeme.out.pnnt("NO");} void test(int i) { System.out.print(a);} void test(int a,int b) { System.out.print(a+b);} } class Test { public static void main(String args[ ] ) { Demo de=new Demo( ); de.test( ); de.test(5); de.test(6,8); } }
有下列程序: #include<iostream> using namespace Std; class Test { public: Test() {n+=2;} ~Test() {n-=3;} static int getNum(){return n;} private: static int n; }; int Test∷n=1; int main()
有如下程序: #include<iostream> using namespace std; Class Test { public: Test() {n+=2;} ~Test() {n-=3;} static int getNum() {return n;} private: static int n; }; int Test::n=1; int main() { Test*p=new Test;
阅读下面程序 class Test implements Runnable { public static void main(String[] args) { Test t=new Test(); t.start(): } public void run() {} } 下列关于上述程序的叙述正确的是
对于类定义: class A{ public: virtual void funcl(){} void func2(){} ); class B:public A{ public: voidfuncl(){cout<<“class Bfunc 1”<<endl;} virtual void func2(){cout<<“class B func 2”<<endl;} }; 下面正确的叙述是( )。
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?()
public class SomeException {  } Class a:  public class a {  public void doSomething() { }  } Class b:  public class b extends a {  public void doSomething() throws SomeException { }  }  Which is true about the two classes?() 
下面程序的运行结果是 #include<iostream.h> class base{ protected: int a; public: base( ){cout<<"0";} }; class basel:virtual base { public: base1( ){cout<<"1";} }; class base2:virtual base{ public:
下面程序的运行结果是( )。 #include<iostream.h> class base{ protected: int a; public: base(){cout<<“0”;} }; Class basel:Virtual base{ public: basel(){cout<<“1”;} }; Class base2:virtual base{ public: base2(){cout<<“2”;)
相关题目
关于下面程序,( )的结论是正确的。 public class J_Test { public static void main(String[] args) { try { return; } finally { System.out.println("1"); }
对于类定义: class A{ public: virtual void funcl(){} void func2(){} ); class B:public A{ public: voidfuncl(){cout<<“class Bfunc 1”<<endl;} virtual void func2(){cout<<“class B func 2”<<endl;} }; 下面正确的叙述是( )。
应在下面程序下划线中填写的正确的语句是( )。 #include <iostream> using namespace std; class A{ public: void test(){cout<< "this is A!";} }; class B:public A{ void test(){ ______ //显示调用基类函数test() cout<< "this is B!"; } }; void main(){}
下列代码的执行结果是( )。 public class Test{ public static void main (String args[ ]){ System.out.println(5/2): } }
下列代码的运行结果是( )。 public class Test { public static void main(String args[]) { System.out.println(89>>1); } }
下列代码的执行结果是( )。 public class Test { public static void main(String args[]) { System.out.println(7/2); } }
阅读下列代码: public class Test{ public static void main(String args[])[ System. out.println(89>>1 ); } }
下列程序的执行结果是( )。 public class Test { public static void main(String args[]) { System.out.println(5/2); } }
对于类定义: class A{ public: virtual void func1( ){} void func2( ){} }; class B:public A{ public: void func1(){cout<<"class B func 1"<<end1;} virtual void func2(){cout<<"class B func 2"<<end1;} }; 下面叙述正确的是(53)。
对于类定义 class A{ public: virtual void func1( ){} void func2( ){} }; class B:public A{ public: void func1( ){cout<<"class B func 1"< < end1;} virtual void func2( ){cout << "class B func2"<< end1;} }; 下面正确的
下面程序的结果是 #include<iostream.h> class A { public: A(){cout<<"construtA" <<endl;} virtual ~A() {cout << "destructA" <<endl;}}; class B:public A { }; class C:public A { }; class D:public B,public C { }; void main() { Dd;}
下列代码中,将引起一个编译错误的行是( )。 1)public class Test{ 2)int m,n; 3)public Test{} 4)public Test(int a){m=a;) 5)public static void main(String args[]){ 6)Test tl,t2; 7)int j,k; 8)j=0;k=0; 9)tl=new Test; 10)t2=new Test(j,k); 11)} 12)}
下列代码中,将引起一个编译错误的行是(  )。
1)public class Test{
2)int m,n;
3)public Test(){}
4)public Test(int a){m=a;)
5)public static void main(String args[]){
6)Test tl,t2;
7)int j,k;
8)j=0;k=0;
9)tl=new Test();
10)t2=new Test(j,k);
11)}
12)}
下列代码的执行结果是( )。 public class Test{ public static void main (String args[ ]){ System.out.println(5/2): } }
下列代码的运行结果是( )。 public class Test { public static void main(String args[]) { System.out.println(89>>1); } }
阅读下列代码: public class Test{ public static void main(String args[])[ System. out.println(89>>1 ); } }
Test.java程序代码如下: public class Test{ public static void main(String[] args){ System.out.println(args[1]); } } 以上程序编译后用java Test 2 3 4 5运行的输出结果是什么? ( )
若有以下程序: #include <iostream> using namespace std; class A { protected: int a; public: A() { a=10; } }; class A1 : public A { public: A1() { a=a+1; } }; class A2 : public A { public: A2 () { a=a+2; } }; class B : public A1,public A2 { public: B(){} void print() { cout<<a<<end1; } }; int main ( ) { B obj; obj.print(); return 0; } 程序运行后的输出结果是( )。
下面程序的结果是 #include<iostream.h> class A { public: A(){cout<<"construtA" <<endl;} virtual ~A() {cout << "destructA" <<endl;}}; class B:public A { }; class C:public A { }; class D:public B,public C { }; void main() { Dd;}
有如下程序: #include <iostream> using namespace std; Class x { protected: int a; public: x() { a=1; } }; class x1 : virtual public x { public: x1() { a+=1; cout<<
广告位招租WX:84302438

免费的网站请分享给朋友吧