//pointXpublicclassfoo(publicstaticvoidmain(String[]args)throwsException{printWriterout=newPrintWriter(newjava.io.outputStreamWriter(System.out),true;out.printIn(Hello”);})WhichstatementatPointXonline1allowsthiscodetocompileandrun?()A.Importjava.io.PrintWriter;B.Includejava.io.PrintWriter;C.Importjava.io.OutputStreamWriter;D.Includejava.io.OutputStreamWriter;E.Nostatementisneeded.

//pointXpublicclassfoo(publicstaticvoidmain(String[]args)throwsException{printWriterout=newPrintWriter(newjava.io.outputStreamWriter(System.out),true;out.printIn(Hello”);})WhichstatementatPointXonline1allowsthiscodetocompileandrun?()

A.Importjava.io.PrintWriter;

B.Includejava.io.PrintWriter;

C.Importjava.io.OutputStreamWriter;

D.Includejava.io.OutputStreamWriter;

E.Nostatementisneeded.


相关考题:

以下是JAVA中正确的入口方法是?() A.publicstaticvoidmain(String[]args){}B.publicstaticvoidmain(Stringargs){}C.publicvoidmain(String[]args){}D.publicstaticintmain(String[]args){}

分析下列java代码ClassA{Publicstaticvoidmain(String[]args){Method();}Staticvoidmethod(){try{System.out.println(hello”)}finally{System.out.println(good-bye”);}}}编译运行后,输出结果是() A.“hello”B.“good-bye”C.“hello”“good-bye”D.代码不能编译

请阅读下面的程序classTest/{privatestaticStringname;static/{name="World";System.out.print(name);/}publicstaticvoidmain(String[]args)/{System.out.print("Hello");Testtest=newTest();/}/}下列选项中,程序运行结果是()。:A.WorldB.HelloC.World HelloD.Hello World

给定以下程序段//insertcodepublicclassfoo(publicstaticvoidmain(String[]args)throwsExceptionprintWriterout=newPrintWriter(new java.io.outputStreamWriter(System.out),true);out.printIn(“Hello”);要使程序能正确运行,在//insertcode处必须添加()语句。A.importjava.io.PrintWriter;B.includejava.io.PrintWriter;C.importjava.io.OutputStreamWriter;D.includejava.io.OutputStreamWriter;

下面main()方法的定义哪些是正确的()。A.publicstaticvoidmain(Stringargs[]){}B.publicstaticvoidmain(String[]){}C.publicstaticvoidmain(String[]args){}D.publicstaticvoidmain(String[]x){}

classFlow{publicstaticvoidmain(String[]args){try{System.out.print(before);doRiskyThing();System.out.print(after);}catch(Exceptionfe){System.out.print(catch);}System.out.println(done);}publicstaticvoiddoRiskyThing()throwsException{//thiscodereturnsunlessitthrowsanException}}可能会产生下面哪两项结果?()A.beforeB.beforecatchC.beforeafterdoneD.beforecatchdone

classParserextendsUtils{publicstaticvoidmain(String[]args){System.out.print(newParser().getInt(42));}intgetInt(Stringarg){returnInteger.parseInt(arg);}}classUtils{intgetInt(Stringarg)throwsException{return42;}}结果为:()A.42B.编译失败C.无输出结果D.运行时异常被抛出

classBird{staticvoidtalk(){System.out.print(chirp);}}classParrotextendsBird{staticvoidtalk(){System.out.print(hello);}publicstaticvoidmain(String[]args){Bird[]birds={newBird(),newParrot()};for(Birdb:birds)b.talk();}}结果为:()A.chirpchirpB.chirphelloC.hellohelloD.编译失败

现有:classParser(类)extends(继承)Utils{publicstaticvoidmain(String[]args){System.out.print(输出打印)(newParser().getInt("42"));}intgetInt(Stringarg){returnInteger.parseInt(arg);}}classUtils{intgetInt(Stringarg)throwsException{return42;}}结果为:()A.42B.编译失败。C.无输出结果。D.运行时异常被抛出。

现有classParserextendsUtils{publicstaticvoidmain(String[]args){try{System.out.print(newParser().getlnt("42"))}catch(Exceptione){System.out.println("Exc");}}intgetlnt(Stringarg)throwsException{returnInteger.parselnt(arg);}}classUtils{intgetlnt(){return42;}}结果是什么?()

现有:classParserextendsUtils{publicstaticvoidmain(String[]args){try{System.out.print(newParser().getlnt(42));}catch(Exceptione){System.out.println(Exc);}}intgetlnt(Stringarg)throwsException{returnInteger.parselnt(arg);}classUtils{intgetlnt(Stringarg){return42;}}结果为()A.42B.ExcC.42ExcD.编译失败

publicclassTestOne{publicstaticvoidmain(String[]args)throwsException{Thread.sleep(3000);System.out.println(”sleep”);}}Whatistheresult?() A.Compilationfails.B.Anexceptionisthrownatruntime.C.Thecodeexecutesnormallyandprints“sleep”.D.Thecodeexecutesnormally,butnothingisprinted.

publicclassStarterextendsThread{privateintx=2;publicstaticvoidmain(String[]args)throwsException{newStarter().makeItSo();}publicStarter(){x=5;start();}publicvoidmakeItSo()throwsException{join();x=x-1;System.out.println(x);}publicvoidrun(){x*=2;}}Whatistheoutputifthemain()methodisrum?()A.4B.5C.8D.9E.Compilationfails.F.Anexceptionisthrownatruntime.G.Itisimpossibletodetermineforcertain.

publicclassTest{publicstaticvoidmain(String[]args){booleanassert=true;if(assert){System.out.println(”assertistrue”);}}}Given:javac-source1.3Test.javaWhatistheresult?() A.Compilationfails.B.Compilationsucceedswitherrors.C.Compilationsucceedswithwarnings.D.Compilationsucceedswithoutwarningsorerrors.

//pointXpublicclassfoo{publicstaticvoidmain(String[]args)throwsException{java.io.printWriterout=newjava.io.PrintWriter{newjava.io.outputStreamWriter(System.out),true;out.printIn(Hello”);}}}WhichstatementatPointXonline1allowsthiscodetocompileandrun?()A.Importjava.io.*;B.Includejava.io.*;C.Importjava.io.PrintWriter;D.Includejava.io.PrintWriter;E.Nostatementisneeded.

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){Strings1=newString(true”);Booleanb1=newBoolean(true);if(s2.equals(b1)){System.out.printIn(Equal”);}}}Whatistheresult?() A.Theprogramrunsandprintsnothing.B.Theprogramrunsandprints“Equal”C.Anerroratline5causescompilationtofail.D.Theprogramrunsbutabortswithanexception.

//PointXpublicclassfoo{publicstaticvoidmain(String[]args)throwsException{jave.io.PrintWriterout=newjave.io.PrintWriter(newjave.io.OutputStreamWriter(System.out),true);out.println(Hello”);}}WhichstatementatPointXonline1isrequiredtoallowthiscodetocompile?()A.Nostatementisrequired.B.importjave.io.*;C.includejava.io.*;D.importjave.io.PrintWriter;E.includejava.io.PrintWriter;

//pointXpublicclassfoo{publicstaticvoidmain(Stringargs)throwsException{java.io.printWriterout=newjava.io.PrintWriter{newjava.io.outputStreamWriter(System.out),true;out.printIn(Hello”);}}}WhichstatementatPointXonline1allowsthiscodetocompileandrun?()A.Importjava.io.*;B.Includejava.io.*;C.Importjava.io.PrintWriter;D.Includejava.io.PrintWriter;E.Nostatementisneeded.

清在下划线处填入代码,使程序正常运行并且输出“Hello!”classTesl______{publicstaticvoidmain(string[]args){Test=newTest();t.start();}Pubhcvoidrun(){System.out.println("Hello!");}}

下列代码段的执行结果是( )。 public class Test { public static void main(String args[ ]) { String s1= new String("hello"); String s2= new String("hello"); System.out.println(s1==s2); System.out.println(s1.equal(s2)); } }A.true falseB.true trueC.false trueD.false false

下列程序段的输出是( )。 public class Test { public static void main (String args[ ]) { String ss1 = new String("hello"); String ss2 = new String("hello"); System.out.println(ssl == ss2); System.out.println (ssequals(ss2)); } }A.true, falseB.true, trueC.false, trueD.false, false

下列代码的执行结果是______。 public class ex55 { public static void main(String args[] ) { String s1=new String("hello"); String s2=new String("hello"); System.out.print (s1==s2); System.out.print (","); System.out.println (s1.equals (s2)); } }A.true, falseB.true, trueC.false, trueD.false, false

作为Java应用程序入口的main方法,其声明格式可以是( )。A、publicstaticvoidmain(String[]args)B、publicstaticintmain(String[]args)C、publicvoidmain(String[]args)D、publicintmain(String[]args)

//point X  public class foo (  public static void main (String[]args) throws Exception {  printWriter out = new PrintWriter (new  java.io.outputStreamWriter (System.out), true;  out.printIn(“Hello”);  }  )   Which statement at PointX on line 1 allows this code to compile and run?()  A、 Import java.io.PrintWriter;B、 Include java.io.PrintWriter;C、 Import java.io.OutputStreamWriter;D、 Include java.io.OutputStreamWriter;E、 No statement is needed.

//point X  public class foo { public static void main (String[]args) throws Exception {  java.io.printWriter out = new java.io.PrintWriter {  new java.io.outputStreamWriter (System.out), true;  out.printIn(“Hello”); }  }  }   Which statement at PointX on line 1 allows this code to compile and run?()  A、 Import java.io.*;B、 Include java.io.*;C、 Import java.io.PrintWriter;D、 Include java.io.PrintWriter;E、 No statement is needed.

单选题//point X  public class foo { public static void main (String[]args) throws Exception {  java.io.printWriter out = new java.io.PrintWriter {  new java.io.outputStreamWriter (System.out), true;  out.printIn(“Hello”); }  }  }   Which statement at PointX on line 1 allows this code to compile and run?()A Import java.io.*;B Include java.io.*;C Import java.io.PrintWriter;D Include java.io.PrintWriter;E No statement is needed.