网友您好, 请在下方输入框内输入要搜索的题目:
题目内容
(请给出正确答案)
publicclassTest{publicstaticvoidmain(Stringargs){classFoo{publicinti=3;}Objecto=(Object)newFoo();Foofoo=(Foo)o;System.out.printIn(foo.i);}}Whatistheresult?()
A.Compilationwillfail.
B.Compilationwillsucceedandtheprogramwillprint“3”
C.CompilationwillsucceedbuttheprogramwillthrowaClassCastExceptionatline6.
D.CompilationwillsucceedbuttheprogramwillthrowaClassCastExceptionatline7.
参考答案
更多 “ publicclassTest{publicstaticvoidmain(Stringargs){classFoo{publicinti=3;}Objecto=(Object)newFoo();Foofoo=(Foo)o;System.out.printIn(foo.i);}}Whatistheresult?() A.Compilationwillfail.B.Compilationwillsucceedandtheprogramwillprint“3”C.CompilationwillsucceedbuttheprogramwillthrowaClassCastExceptionatline6.D.CompilationwillsucceedbuttheprogramwillthrowaClassCastExceptionatline7. ” 相关考题
考题
classFoo{privateintx;publicFoo(intx){this.x=x;}publicvoidsetX(intx){this.x=x;}publicintgetX(){returnx;}}publicclassGamma{staticFoofooBar(Foofoo){foo=newFoo(100);returnfoo;}publicstaticvoidmain(String[]args){Foofoo=newFoo(300);System.out.print(foo.getX()+-);FoofooFoo=fooBar(foo);System.out.print(foo.getX()+-);System.out.print(fooFoo.getX()+-);foo=fooBar(fooFoo);System.out.print(foo.getX()+-);System.out.prmt(fooFoo.getX());}}Whatistheoutputofthisprogram?()
考题
publicclassTest{publicstaticvoidmain(String[]args){stringfoo=blue”;stringbar=foo;foo=green”;System.out.printIn(bar);}}Whatistheresult?()
A.Anexceptionisthrown.B.Thecodewillnotcompile.C.Theprogramprints“null”D.Theprogramprints“blue”E.Theprogramprints“green”
考题
publicclassTest{2.publicstaticvoidmain(Stringargs[]){3.classFoo{4.publicinti=3;5.}6.Objecto=(Object)newFoo();7.Foofoo=(Foo)o;8.System.out.printIn(foo.i);9.}10.}Whatistheresult?()
A.Compilationwillfail.B.Compilationwillsucceedandtheprogramwillprint“3”C.CompilationwillsucceedbuttheprogramwillthrowaClassCastExceptionatline6.D.CompilationwillsucceedbuttheprogramwillthrowaClassCastExceptionatline7.
考题
publicclassTest{publicstaticvoidleftshift(inti,intj){i=j;}publicstaticvoidmain(Stringargs[]){inti=4,j=2;leftshift(i,j);System.out.printIn(i);}}Whatistheresult?()
A.2B.4C.8D.16E.Thecodewillnotcompile.
考题
publicclasstest{publicstaticvoidadd3(Integeri)intval=i.intValue();val+=3;i=newInteger(val);}publicstaticvoidmain(Stringargs[]){Integeri=newInteger(0);add3(i);system.out.printIn(i.intValue());}Whatistheresult?()A.Compilationwillfail.B.Theprogramprints“0”.C.Theprogramprints“3”.D.Compilationwillsucceedbutanexceptionwillbethrownatline3.
考题
publicclassTest{publicstaticvoidmain(Stringargs[]){classFoo{publicinti=3;}Objecto=(Object)newFoo();Foofoo=(Foo)o;System.out.println(i=+foo.i);}}Whatistheresult?()
A.i=3B.Compilationfails.C.AClassCastExceptionisthrownatline6.D.AClassCastExceptionisthrownatline7.
考题
publicclassTest{publicstaticvoidmain(Stringargs){stringfoo=blue”;stringbar=foo;foo=green”;System.out.printIn(bar);}}Whatistheresult?()
A.Anexceptionisthrown.B.Thecodewillnotcompile.C.Theprogramprints“null”D.Theprogramprints“blue”E.Theprogramprints“green”
考题
publicclassFooimplementsRunnable(publicvoidrun(Threadt){system.out.printIn(Running.”);}publicstaticvoidmain(Stringargs){newthread(newFoo()).start();})Whatistheresult?()
A.Anexceptionisthrown.B.Theprogramexistswithoutprintinganything.C.Anerroratline1causescompilationtofail.D.Anerroratline6causesthecompilationtofail.E.“Running”isprintedandtheprogramexits.
考题
publicclassTest{publicstaticvoidleftshift(inti,intj){i=j;}publicstaticvoidmain(Stringargs){inti=4,j=2;leftshift(i,j);System.out.printIn(i);}}Whatistheresult?()
A.2B.4C.8D.16E.Thecodewillnotcompile.
热门标签
最新试卷