1.classA{2.publicbytegetNumber(){3.return1;4.}5.}6.7.classBextendsA{8.publicshortgetNumber(){9.return2;10.}11.12.publicstaticvoidmain(Stringargs[]){13.Bb=newB();14.System.out.printIn(b.getNumber())15.}16.}Whatistheresult?()A.Compilationsucceedsand1isprinted.B.Compilationsucceedsand2isprinted.C.Anerroratline8causescompilationtofail.D.Anerroratline14causescompilationtofail.E.Compilationsucceedsbutanexceptionisthrownatline14.

1.classA{2.publicbytegetNumber(){3.return1;4.}5.}6.7.classBextendsA{8.publicshortgetNumber(){9.return2;10.}11.12.publicstaticvoidmain(Stringargs[]){13.Bb=newB();14.System.out.printIn(b.getNumber())15.}16.}Whatistheresult?()

A.Compilationsucceedsand1isprinted.

B.Compilationsucceedsand2isprinted.

C.Anerroratline8causescompilationtofail.

D.Anerroratline14causescompilationtofail.

E.Compilationsucceedsbutanexceptionisthrownatline14.


相关考题:

1.classA{2.publicbytefileNumber(){3.returnl;4.}5.}6.7.ClassBextendsA{8.publicshortgetNumber(){9.return2;10.}11.12.publicshortgetNumber(){13.Bb=newB();14.System.out.printIn(b.getNumber());15.}16.}Whatistheresult()?A.Compilationsucceedsandlisprinted.B.Compilationsucceedsand2printed.C.Anerroratline8causecompilationtofail.D.Anerroratline14causecomplicationtofail.E.Complicationsucceedsbutanexceptionisthrownatline14.

1.classA{2.publicStringtoString(){3.return4”;4.}5.}6.classBextendsA{7.publicStringtoString(){8.returnsuper.toString()+3”;9.}10.}11.publicclassTest{12.publicstaticvoidmain(String[]args){13.System.out.printIn(newB());14.}15.}Whatistheresult?()A.Compilationsucceedsand4isprinted.B.Compilationsucceedsand43isprinted.C.Anerroronline9causescompilationtofail.D.Anerroronline14causescompilationtofail.E.Compilationsucceedsbutanexceptionisthrownatline9.

1.classA{2.publicintgetNumber(inta){3.returna+1;4.}5.}6.7.classBextendsA{8.publicintgetNumber(inta){9.returna+210.}11.12.publicstaticvoidmain(Stringargs[]){13.Aa=newB();14.System.out.printIn(a.getNumber(0));15.}16.}Whatistheresult?()A.Compilationsucceedsand1isprinted.B.Compilationsucceedsand2isprinted.C.Anerroratline8causescompilationtofail.D.Anerroratline13causescompilationtofail.E.Anerroratline14causescompilationtofail.

Whatproducesacompilererror?() A.classA{publicA(intx){}}B.classA{}classBextendsA{B(){}}C.classA{A(){}}classB{publicB(){}}D.classZ{publicZ(int){}}classAextendsZ{}

InwhichtwocasesdoesthecompilersupplyadefaultconstructorforclassA?() A.classA{}B.classA{publicA(){}}C.classA{publicA(intx){}}D.classZ{}classAextendsZ{voidA(){}}

publicclassA{2.voidA(){3.System.out.println(ClassA”);4.}5.publicstaticvoidmain(String[]args){6.newA();7.}8.}Whatistheresult?() A.ClassAB.Compilationfails.C.Anexceptionisthrownatline2.D.Anexceptionisthrownatline6.E.Thecodeexecuteswithnooutput.

有如下模板声明:templatetypename T1,typename 12class A;下列声明中,与上述声明不等价的是A.templateclass T1,class T2class A;B.templateclass T1,typename T2class A;C.templatetypename TI,class T2class A;D.templatetypename T1,T2class A;

下面能表示一个正确的类的是( )。A.class AB.class A()C.class A[]D.class A{}

若有类A与类B,则以下哪个不属于类的组合关系A.class A { B b; };B.class A { B* p; };C.class A { B bb[3]; };D.class A { public: fun(B b); };