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.

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.


相关考题:

importjava.util.*;publicclassLetterASort{publicstaticvoidmain(String[]args){ArrayListstrings=newArrayList();strings.add(?aAaA”);strings.add(”AaA”);strings.add(?aAa”);strings.add(”AAaa”);Collections.sort(strings);for(Strings:strings){System.out.print(s+);}}}Whatistheresult?()A.Compilationfails.B.aAaAaAaAAaaAaAC.AAaaAaAaAaaAaAD.AaAAAaaaAaAaAaE.aAaAaAaAaAAAaaF.Anexceptionisthrownatruntime.

publicclassX{publicstaticvoidmain(String[]args){Strings1=newString(true”);Booleanb1=newBoolean(true);if(s2.equals(b1)){System.out.printIn(Equal”);}}}Whatistheresult?() A.Theprogramrunsandprintsnothing.B.Theprogramrunsandprints“Equal”C.Anerroratline5causescompilationtofail.D.Theprogramrunsbutabortswithanexception.

publicclassfoo{publicstaticvoidmain(String[]args){Strings;system.out.printIn(s=”+s);}}Whatistheresult?() A.Thecodecompilesand“s=”isprinted.B.Thecodecompilesand“s=null”isprinted.C.Thecodedoesnotcompilebecausestringsisnotinitialized.D.Thecodedoesnotcompilebecausestringscannotbereferenced.E.Thecodecompiles,butaNullPointerExceptionisthrownwhentoStringiscalled.

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.

下列程序的执行结果是______。 public class Test9 { public static void main(String[] args) { String s1 = new String("I am a girl"); String s2 = new String("I am a girl"); System.out.println (s1.equal (s2)); } }A.trueB.假C.I amgirlD.都不正确

String s = "Hello";s = s + " world!";这两行代码执行后,原始的String 对象中的内容到底变了没有?

1、写出以下程序的运行结果? public class Test{ public static void main(String argv[]){ String s = new String("hello"); myMethod(s); System.out.print("s=" + s); } public static void myMethod(String s){ s = s + "!"; } }A.s=hello!B.s=helloC.hello!D.hello

写出以下程序的运行结果? public class Test{ public static void main(String argv[]){ String s = new String("hello"); myMethod(s); System.out.print("s=" + s); } public static void myMethod(String s){ s = s + "!"; } }A.s=hello!B.s=helloC.hello!D.hello