classA{publicbytegetNumber(){return1;}}classBextendsA{publicshortgetNumber(){return2;}publicstaticvoidmain(Stringargs){Bb=newB();System.out.printIn(b.getNumber())}}Whatistheresult?() A.Compilationsucceedsand1isprinted.B.Compilationsucceedsand2isprinted.C.Anerroratline8causescompilationtofail.D.Anerroratline14causescompilationtofail.E.Compilationsucceedsbutanexceptionisthrownatline14.
classA{publicbytegetNumber(){return1;}}classBextendsA{publicshortgetNumber(){return2;}publicstaticvoidmain(Stringargs){Bb=newB();System.out.printIn(b.getNumber())}}Whatistheresult?()
A.Compilationsucceedsand1isprinted.
B.Compilationsucceedsand2isprinted.
C.Anerroratline8causescompilationtofail.
D.Anerroratline14causescompilationtofail.
E.Compilationsucceedsbutanexceptionisthrownatline14.
相关考题:
class A{public int getNumber(int a){return a+1;}}class B extends A{public int getNumber(int a, char c){return a+2;}public static void main(String[] args){B b=new B();System.out.println(b.getNumber(0));}}what is the result?()A.compilation succeeds and 1 is printedB.compilation succeeds and 2 is printedC.compilation succeeds and 3 is printedD.An error at this program cause compilation to fail
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.
Whichstatements,wheninsertedattheindicatedpositioninthefollowingcode,willcausearuntimeexceptionwhenattemptingtoruntheprogram?()classA{}classBextendsA{}classCextendsA{}publicclassQ3ae4{publicstaticvoidmain(Stringargs[]){Ax=newA();By=newB();Cz=newC();//insertstatementhere}}A.x=y;B.z=x;C.y=(B)x;D.z=(C)y;E.y=(A)y;
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.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.
classA{publicA(){System.out.println(hellofroma”);}}classBextendsA{publicB(){System.out.println(hellofromb”);super();}}publicclassTest{publicstaticvoidmain(Stringargs[]){Aa=newB();}}Whatistheresultwhenmainisexecuted?()A.Compilationfails.B.hellofromaC.hellofrombD.hellofrombhellofromaE.hellofromahellofromb
classA{publicbytegetNumber(){return1;}}classBextendsA{publicshortgetNumber(){return2;}publicstaticvoidmain(Stringargs[]){Bb=newB();System.out.println(b.getNumber());}}Whatistheresult?() A.1B.2C.Anexceptionisthrownatruntime.D.Compilationfailsbecauseofanerrorinline8.E.Compilationfailsbecauseofanerrorinline14.
classA{publicStringtoString(){return4”;}}classBextendsA{8.publicStringtoString(){returnsuper.toString()+3”;}}publicclassTest{publicstaticvoidmain(Stringargs){System.out.printIn(newB());}}Whatistheresult?()A.Compilationsucceedsand4isprinted.B.Compilationsucceedsand43isprinted.C.Anerroronline9causescompilationtofail.D.Anerroronline14causescompilationtofail.E.Compilationsucceedsbutanexceptionisthrownatline9.
classA{publicintgetNumber(inta){returna+1;}}classBextendsA{publicintgetNumber(inta){returna+2}publicstaticvoidmain(Stringargs){Aa=newB();System.out.printIn(a.getNumber(0));}}Whatistheresult?() A.Compilationsucceedsand1isprinted.B.Compilationsucceedsand2isprinted.C.Anerroratline8causescompilationtofail.D.Anerroratline13causescompilationtofail.E.Anerroratline14causescompilationtofail.