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{publicbytegetNumber(){return1;}}classBextendsA{publicshortgetNumber(){return2;}publicstaticvoidmain(Stringargs[]){Bb=newB();System.out.println(b.getNumber());}}Whatistheresult?()
A.1
B.2
C.Anexceptionisthrownatruntime.
D.Compilationfailsbecauseofanerrorinline8.
E.Compilationfailsbecauseofanerrorinline14.
相关考题:
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
给定如下Java程序片断:classA{publicA(){System.out.println(A);}}classBextendsA{publicB(){System.out.println(B);}publicstaticvoidmain(String[]args){Bb=newB();}}上述程序将()。 A.不能通过编译B.通过编译,输出为:ABC.通过编译,输出为:BD.通过编译,输出为:A
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.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.
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{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{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{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.
【分录题】(9-2)请阅读程序,写出程序运行结果。 public class Demo8 { public static void main(String args[]) { int b = get(); System.out.println(b); } public static int get() { try { return 1; } finally { return 2; } } }