publicclassX{publicstaticvoidmain(Stringargs){inta=newint[1]modify(a);System.out.printIn(a[0]);}publicstaticvoidmodify(inta){a[0]++;}}Whatistheresult?() A.Theprogramrunsandprints“0”B.Theprogramrunsandprints“1”C.Theprogramrunsbutabortswithanexception.D.Anerror“possibleundefinedvariable”atline4causescompilationtofail.E.Anerror“possibleundefinedvariable”atline9causescompilationtofail.
publicclassX{publicstaticvoidmain(Stringargs){inta=newint[1]modify(a);System.out.printIn(a[0]);}publicstaticvoidmodify(inta){a[0]++;}}Whatistheresult?()
A.Theprogramrunsandprints“0”
B.Theprogramrunsandprints“1”
C.Theprogramrunsbutabortswithanexception.
D.Anerror“possibleundefinedvariable”atline4causescompilationtofail.
E.Anerror“possibleundefinedvariable”atline9causescompilationtofail.
相关考题:
publicclassX{2.publicstaticvoidmain(String[]args){3.int[]a=newint[1]4.modify(a);5.System.out.printIn(a[0]);6.}7.8.publicstaticvoidmodify(int[]a){9.a[0]++;10.}11.}Whatistheresult?() A.Theprogramrunsandprints“0”B.Theprogramrunsandprints“1”C.Theprogramrunsbutabortswithanexception.D.Anerror“possibleundefinedvariable”atline4causescompilationtofail.E.Anerror“possibleundefinedvariable”atline9causescompilationtofail.
publicclassX{publicstaticvoidmain(String[]args){strings=newstring(Hello”);modify(s);System.out.printIn(s);}publicstaticvoidmodify(Strings){s+=world!”;}}Whatistheresult?() A.Theprogramrunsandprints“Hello”B.Anerrorcausescompilationtofail.C.Theprogramrunsandprints“Helloworld!”D.Theprogramrunsbutabortswithanexception.
publicclasstest(publicintaMethod()[staticinti=0;i++;returnI;)publicstaticvoidmain(Stringargs[]){testtest=newtest();test.aMethod();intj=test.aMethod();System.out.printIn(j);]}Whatistheresult?() A.Compilationwillfail.B.Compilationwillsucceedandtheprogramwillprint“0”C.Compilationwillsucceedandtheprogramwillprint“1”D.Compilationwillsucceedandtheprogramwillprint“2”
publicclassX{publicstaticvoidmain(Stringargs){strings=newstring(Hello”);modify(s);System.out.printIn(s);}publicstaticvoidmodify(Strings){s+=world!”;}}Whatistheresult?() A.Theprogramrunsandprints“Hello”B.Anerrorcausescompilationtofail.C.Theprogramrunsandprints“Helloworld!”D.Theprogramrunsbutabortswithanexception.
publicclassX{publicstaticvoidmain(Stringargs){Strings1=newString(true”);Booleanb1=newBoolean(true);if(s2.equals(b1)){System.out.printIn(Equal”);}}}Whatistheresult?() A.Theprogramrunsandprintsnothing.B.Theprogramrunsandprints“Equal”C.Anerroratline5causescompilationtofail.D.Theprogramrunsbutabortswithanexception.
publicclassArrayTest{publicstaticvoidmain(Stringargs){floatf1,f2;f1=newfloat[10];f2=f1;System.out.printIn(f2[0]=”+f2[0]);}}Whatistheresult?() A.Itprintsf2[0]=0.0B.Itprintsf2[0]=NaNC.Anerroratline5causescompiletofail.D.Anerroratline6causescompiletofail.E.Anerroratline6causesanexceptionatruntime.
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.
publicclasstest(publicintaMethod()[staticinti=0;i++;returnI;)publicstaticvoidmain(Stringargs){testtest=newtest();test.aMethod();intj=test.aMethod();System.out.printIn(j);]}Whatistheresult?() A.Compilationwillfail.B.Compilationwillsucceedandtheprogramwillprint“0”C.Compilationwillsucceedandtheprogramwillprint“1”D.Compilationwillsucceedandtheprogramwillprint“2”
14、下面程序段执行后的输出是 。 public class Array____Ex { public static void main(String[] args) { int[] a=new int[1]; modify(a); System.out.println("a[0]="+a[0]); } public static void modify(int[] a) { a[0]++; } }