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.Comp

题目
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{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?() ”相关问题
  • 第1题:

    publicclassTest{publicstaticvoidmain(Stringargs[]){classFoo{publicinti=3;}Objecto=(Object)newFoo();Foofoo=(Foo)o;System.out.println(i=+foo.i);}}Whatistheresult?()

    A.i=3

    B.Compilationfails.

    C.AClassCastExceptionisthrownatline6.

    D.AClassCastExceptionisthrownatline7.


    参考答案:A

  • 第2题:

    publicclassFooimplementsRunnable(publicvoidrun(Threadt){system.out.printIn(Running.”);}publicstaticvoidmain(Stringargs){newthread(newFoo()).start();})Whatistheresult?()

    A.Anexceptionisthrown.

    B.Theprogramexistswithoutprintinganything.

    C.Anerroratline1causescompilationtofail.

    D.Anerroratline6causesthecompilationtofail.

    E.“Running”isprintedandtheprogramexits.


    参考答案:C

  • 第3题:

    publicclassTest{2.publicstaticvoidmain(Stringargs){3.unsignedbyteb=0;4.b--;5.6.}7.}Whatisthevalueofbatline5?()

    A.-1

    B.255

    C.127

    D.Compilationwillfail.

    E.Compilationwillsucceedbuttheprogramwillthrowanexceptionatline4.


    参考答案:D

  • 第4题:

    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”


    参考答案:D

  • 第5题:

    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.


    参考答案:B