packagetest1;publicclassTest1{staticintx=42;}packagetest2;publicclassTest2extendstest1.Test1{publicstaticvoidmain(String[]args){System.out.println(x=+x);}}Whatistheresult?() A.x=0B.x=42C.Compilationfailsbecauseofanerrorinline2ofclassTest2.D.Compilationfailsbecauseofanerrorinline3ofclassTest1.E.Compilationfailsbecauseofanerrorinline4ofclassTest2.
packagetest1;publicclassTest1{staticintx=42;}packagetest2;publicclassTest2extendstest1.Test1{publicstaticvoidmain(String[]args){System.out.println(x=+x);}}Whatistheresult?()
A.x=0
B.x=42
C.Compilationfailsbecauseofanerrorinline2ofclassTest2.
D.Compilationfailsbecauseofanerrorinline3ofclassTest1.
E.Compilationfailsbecauseofanerrorinline4ofclassTest2.
相关考题:
classTestMain{staticintx=2;static{x=4;}publicstaticvoidmain(String...args){inty=x+1;System.out.println(y);}}和命令行:javaTestMain结果为:() A.3B.5C.编译失败D.运行时异常被抛出
classTop{staticintx=1;publicTop(inty){x*=3;}}classMiddleextendsTop{publicMiddle(){x+=1;}publicstaticvoidmain(String[]args){Middlem=newMiddle();System.out.println(x);}}结果为:() A.1B.2C.3D.编译失败
现有:classTestMain{staticintx=2;static{x=4;}publicstaticvoidmain(String...args){inty=x+1;System.out.println(y);}}和命令行:javaTestMain结果为:() A.3B.5C.编译失败D.运行时异常被抛出
现有:classTop{staticintX=l;publicTop(){x*=3;}}classMiddleextendsTop{publicMiddle(){x+=l;}publicstaticvoidmain(String[]args){Middlem=newMiddle();System.out.println(x);}}结果是什么?() A.2B.3C.4D.编译失败
现有:classTop{staticintx=l;publicTop(inty){x*=3;}}classMiddleextendsTop{publicMiddle(){x+=1;)publicstaticvoidmain(String[]args){Middlem=newMiddle();System.out.println(x);}}结果为:() A.1B.2C.3D.编译失败
publicstaticvoidmain(String[]args){try{args=null;args[0]=test”;System.out.println(args[0]);}catch(Exceptionex){System.out.println(”Exception”);}catch(NullPointerExceptionnpe){System.out.println(”NullPointerException”);}}Whatistheresult?()A.testB.ExceptionC.Compilationfails.D.NullPointerException
publicclassTest{privatestaticint[]x;publicstaticvoidmain(String[]args){System.out.println(x[0]);}}Whatistheresult?() A.0B.nullC.Compilationfails.D.ANullPointerExceptionisthrownatruntime.E.AnArrayIndexOutOfBoundsExceptionisthrownatruntime.
publicclassTest{publicstaticvoidmain(String[]args){intx=0;assert(x0)?assertionfailed”:assertionpassed”;System.out.println(Finished”);}}Whatistheresult?() A.finishedB.Compilationfails.C.AnAssertionErroristhrownandfinishedisoutput.D.AnAssertionErroristhrownwiththemessage“assertionfailed”.E.AnAssertionErroristhrownwiththemessage“assertionpassed”.
publicclassTest{publicstaticvoidmain(String[]args){intx=0;assert(x>0):“assertionfailed”;System.out.println(“finished”);}}Whatistheresult?() A.finishedB.Compilationfails.C.AnAssertionErroristhrown.D.AnAssertionErroristhrownandfinishedisoutput.