问题 单项选择题

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

A.
  int[] myArray=10,20,30,40;
  try
     FileOutputStream f=new FileOutputStream("ints.dat");
     DataOutputStream ______ =new DataOutputStream(f);
     for(int i=0;i<myArray.length;i++)dos.writeInt(myArray[i]);
     dos.close();
     System.out.println("Have written binary file ints.dat");
   catch(IOException ioe)
     System.out.println("IOException");
  
 

程序中下画线处应填入的正确选项是A) myArray

B.dos

C.ioe

D.ints

答案

参考答案:B

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

判断题
单项选择题