A.Thecodedoesnotcompile.
B.Thecoderunsandnochangeismadetothefile.
C.Thecoderunsandsetsthelengthofthefileto0.
D.Anexceptionisthrownbecausethefileisnotclosed.
E.Thecoderunsanddeletesthefilefromthefilesystem.
第1题:
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);
第2题:
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”);
第3题:
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”);
第4题:
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.
第5题:
为了向文件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) { }