itgle.com

Thefilefile.txt”existsonthefilesystemandcontsinsASCIItext.Given:try{Filef=newFile(file.txt”);OutputStreamout=newFileOutputStream(f,true);}catch(IOException){}Whatistheresult?()A.Thecodedoesnotcompile.B.Thecoderunsandnochangeismadetothefile.C.Thecoderunsan

题目
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.


相似考题
参考答案和解析
参考答案:A
更多“Thefilefile.txt”existsonthefilesystemandcontsinsASCIItext.Given:try{Filef=newFile(file.txt”);OutputStreamout=newFileOutputStream(f,true);}catch(IOException){}Whatistheresult?() ”相关问题
  • 第1题:

    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);


    参考答案:C, E

  • 第2题:

    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”);


    参考答案:B

  • 第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.


    参考答案:A

  • 第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) { }


    C