当前位置:IT认证>软件水平

问题:[选择题]

[单项选择题] 阅读下面写文件的程序 import java.io.*: public class WriteFile  public static void main(String[]


A.
  int[]myArray=10,20,30,40;
  try
     FileOutputStreamf=newFileOutputStream("ints.dat");
     DataOutputStream______=newDataOutputStream(f);
     for(inti=0;i<myArray.length;i++)dos.writeInt(myArray[i]);
     dos.close();
     System.out.println("Havewrittenbinaryfileints.dat");
  catch(IOExceptionioe)
     System.out.println("IOException");
  
 

程序中下画线处应填入的正确选项是A)myArray
B.dos
C.ioe
D.ints

参考答案: B

  参考解析

本程序中需要将DataOutputStream实例化,由于后边用到了dos.writeInt,由此可看出实例化后的名称为dos。所以下画线处应填写dos。

微信端