1.publicclassa{
2.publicvoidmethod1(){
3.try{
4.Bb=newb();
5.b.method2();
6.//morecodehere
7.}catch(TestExceptionte){
8.thrownewRuntimeException(te);
9.}
10.}
11.}
1.publicclassb{
2.publicvoidmethod2()throwsTestException{
3.//morecodehere
4.}
5.}
1.publicclassTestExceptionextendsException{
2.}
Given:
31.publicvoidmethod(){
32.Aa=newa();
33.a.method1();
34.}
WhichistrueifaTestExceptionisthrownonline3ofclassb?()
第1题:
A.ClassA
B.Compilationfails.
C.Anexceptionisthrownatline2.
D.Anexceptionisthrownatline6.
E.Thecodeexecuteswithnooutput.
第2题:
23、假定类A已经定义,对于以A为基类的单一继承类B,以下定义中正确的是:()
A.class B:public A{//...};
B.class A:public B{//...};
C.class B:public class A{//...};
D.class A:class B public{//...};
第3题:
下列哪些是合法的类定义语句
A.public class A {}
B.class A extends Exception,I0Exception {}
C.public class 1A extends Object
D.public class String {}
第4题:
【单选题】下面程序段的输出结果是() 。 public class A{ public static void main(String args[]) { String str ="Hello,"; str=str+"Guys!"; System.out.println(str); } }
A.hello,guys!
B.hello,
C.guys!
D.编译不通过
第5题:
下面的代码使用了面向对象的什么特性?() public class A{ public void DoSomething(){} } public class B : A{ new public void DoSomething(){ base.DoSomething();} }
A.继承性
B.多态性
C.封装性
D.关联性
第6题:
若要使用两个泛型类型来声明一个名为A的类,请使用
A.public class A<E> { ... }
B.public class A<E, F> { ... }
C.public class A(E) { ... }
D.public class A(E, F) { ... }