publicclassTest{privatestaticint[]x;publicstaticvoidmain(String[]args){System.out.println(x[0]);}}Whatistheresult?() A.0B.nullC.Compilationfails.D.ANullPointerExceptionisthrownatruntime.E.AnArrayIndexOutOfBoundsExceptionisthrownatruntime.

publicclassTest{privatestaticint[]x;publicstaticvoidmain(String[]args){System.out.println(x[0]);}}Whatistheresult?()

A.0

B.null

C.Compilationfails.

D.ANullPointerExceptionisthrownatruntime.

E.AnArrayIndexOutOfBoundsExceptionisthrownatruntime.


相关考题:

执行下面程序段,屏幕上将输出( )。 public class Test { private int x=10,y=20; public Test (int x,int y) { System.out.println (x+this.x); System.out.println (y+y); } public static void main (String[] args) { Testt= new Test(30,50); } }A.无输出B.20 40C.40 100D.40 70

classRectangle{publicstaticvoidmain(String[]args){int[]x={1,2,3};x[1]=(x[1]〉1)?x[2]:0;System.out.println(x[1]);}}结果为:() A.0B.1C.2D.3

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

下列语句序列执行后,x的值是_________。publicclasstest{publicstaticvoidmain(string[]args){inta=2;intb=3;intx=4;x=++a*x;system.out.println(x);}} A.13B.10C.11D.12

publicclassTest{publicstaticvoidmain(String[]args){Stringstr=NULL;System.out.println(str);}}Whatistheresult?() A.NULLB.Compilationfails.C.Thecoderunswithnooutput.D.Anexceptionisthrownatruntime.

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.

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.

interface A{int x = 0;}class B{int x =1;}class C extends B implements A {public void pX(){System.out.println(x);}public static void main(String[] args) {new C().pX();}}