网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)
Thefilefile.txt”existsonthefilesystemandcontsinsASCIItext.Given:try{Filef=newFile(file.txt”);OutputStreamout=newFileOutputStream(f,true);}catch(IOException){}Whatistheresult?()

A.Thecodedoesnotcompile.

B.Thecoderunsandnochangeismadetothefile.

C.Thecoderunsandsetsthelengthofthefileto0.

D.Anexceptionisthrownbecausethefileisnotclosed.

E.Thecoderunsanddeletesthefilefromthefilesystem.


参考答案

更多 “ Thefilefile.txt”existsonthefilesystemandcontsinsASCIItext.Given:try{Filef=newFile(file.txt”);OutputStreamout=newFileOutputStream(f,true);}catch(IOException){}Whatistheresult?() A.Thecodedoesnotcompile.B.Thecoderunsandnochangeismadetothefile.C.Thecoderunsandsetsthelengthofthefileto0.D.Anexceptionisthrownbecausethefileisnotclosed.E.Thecoderunsanddeletesthefilefromthefilesystem. ” 相关考题
考题 importjava.io.*;publicclassForestimplementsSerializable{privateTreetree=newTree();publicstaticvoidmain(String[]args){Forestf=newForest();try{FileOutputStreamfs=newFileOutputStream(”Forest.ser”);ObjectOutputStreamos=newObjectOutputStream(fs);os.writeObject(f);os.close();}catch(Exceptionex){ex.printStackTrace();}}}classTree{}Whatistheresult?()A.Compilationfails.B.Anexceptionisthrownatruntime.C.AninstanceofForestisserialized.D.AinstanceofForestandaninstanceofTreearebothserialized.

考题 staticvoidtest()throwsError{if(true)thrownewAssertionError();System.out.print(”test);}publicstaticvoidmain(String[]args){try{test();}catch(Exceptionex){System.out.print(”exception);}System.out.print(”elld);}Whatistheresult?()A.endB.Compilationfails.C.exceptionendD.exceptiontestendE.AThrowableisthrownbymain.F.AnExceptionisthrownbymain.

考题 importjava.io.IOException;publicclassExceptionTest(publicstaticvoidmain(String[]args)try(methodA();)catch(IOExceptione)(system.out.printIn(CaughtIOException”);)catch(Exceptione)(system.out.printIn(CaughtException”);))publicvoidmethodA(){thrownewIOException();}Whatistheresult?()A.Thecodewillnotcompile.B.Theoutputiscaughtexception.C.TheoutputiscaughtIOException.D.Theprogramexecutesnormallywithoutprintingamessage.

考题 publicclassAextendsThread{A(){setDaemon(true);}publicvoidrun(){(newB()).start();try{Thread.sleep(60000);}catch(InterruptedExceptionx){}System.out.println(Adone”);}classBextendsThread{publicvoidrun(){try{Thread.sleep(60000);}catch(InterruptedExceptionx){}System.out.println(Bdone”);}}publicstaticvoidmain(String[]args){(newA()).start();}}Whatistheresult?()A.AdoneB.BdoneC.AdoneBdoneD.BdoneAdoneE.Thereisnoexceptionthattheapplicationwillprintanything.F.Theapplicationoutputs“Adone”and“Bdone”,innoguaranteedorder.

考题 WhichtwoconstructanOutputSreamthatappendstothefile“file.txt”?() A.OutputStreamout=newFileOutputStream(“file.txt”);B.OutputStreamout=newFileOutputStream(“file.txt”,“append”);C.FileOutputStreamout=newFileOutputStream(“file.txt”,true);D.FileOutputStreamout=newFileOutputStream(newfile(“file.txt”));E.OutputStreamout=newFileOutputStream(newFile(“file.txt”)true);

考题 importjava.io.IOException;publicclassExceptionTest(publicstaticvoidmain(Stringargs)try(methodA();)catch(IOExceptione)(system.out.printIn(CaughtIOException”);)catch(Exceptione)(system.out.printIn(CaughtException”);))publicvoidmethodA(){thrownewIOException();}Whatistheresult?()A.Thecodewillnotcompile.B.Theoutputiscaughtexception.C.TheoutputiscaughtIOException.D.Theprogramexecutesnormallywithoutprintingamessage.

考题 Whatwritesthetext“”totheendofthefile“file.txt”?() A.OutputStreamout=newFileOutputStream(“file.txt”); Out.writeBytes(“/n”);B.OutputStreamos=newFileOutputStream(“file.txt”,true); DataOutputStreamout=newDataOutputStream(os);out.writeBytes(“/n”);C.OutputStreamos=newFileOutputStream(“file.txt”); DataOutputStreamout=newDataOutputStream(os);out.writeBytes(“/n”);D.OutputStreamos=newOutputStream(“file.txt”,true); DataOutputStreamout=newDataOutputStream(os);out.writeBytes(“/n”);

考题 为了向文件hello.txt尾部追加数据,下列哪个是正确创建指向hello.txt的流()A.try{ OutputStream out=new FileOutputStream("hello.txt"); }catch(IOException e) { }B.try{ OutputStream out=new FileOutputStream("hello.txt",true); }catch(IOException e) { }C.try{ OutputStream out=new FileOutputStream("hello.txt",false); }catch(IOException e) { }D.try{ OutputStream out=new OutputStream("hello.txt",true); }catch(IOException e) { }

考题 17、下面哪些选项能够创建一个OutputStream流,并且可以将内容附加到“file.txt”文件中?()A.OutputStream out=new FileOutputStream(“file.txt”);B.OutputStream out=new FileOutputStream(“file.txt”,”append”);C.FileOutputStream out=new FileOutputStream(“file.txt”,true);D.FileOutputStream out=new FileOutputStream(“file.txt”);