阅读下面程序 import java.io.*; public class ByteStreamTest { public static void main(String[] args) { int[] myArray={10,20,30,40}; try { DataOutputStream dos=new DataOutputStream (new ______("ints.dat")); 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.FileOutputStream
B.ByteArrayOutputStream
C.BufferedOutputStream
D.FileWriter
第1题:
将下面程序补充完整。
include <iostream>
using namespace std;
class Base{
public:
【 】 fun(){return 0;} //声明虚函数
};
class Derived:public Base{
public:
x,y;
void SetVal(int a,int b){}
int fun(){return x+y;}
};
void 【 】 SetVal(int a,int b){x=a;y=b;} //类Derived成员函数
void main(){
Derived d;
cout<<d.fun()<<endl;
}
第2题:
第3题:
以下叙述正确的是()。
A.main方法必须是public方法
B.构造方法必须是public方法
C.Java应用程序的文件名可以是任意的
D.构造方法应该声明为void类型
第4题:
下面程序的结果是 ______。 #include<iostream.h> class A{ public: virtual void fun()=0{}; }; class B:public A{ public: void fun () {cout<< "new file" ;} }; class C: public A{ public: void fun (){cout<<"open file"<< " " } }; class D: public A{ public: void fun () {cout<< "save file\n" ;} }; void main() { A a,*p; B b; C c; D d; p=&c; p->fun (); p=&b; p->fun (); p=&d; p->fun(); }
A.new file open file save file
B.new file new file new file
C.编译出错
D.open file new file save file
第5题:
第6题:
以下叙述正确的是()
A.main方法必须是public方法
B.构造方法必须是public方法
C.Java应用程序的文件名可以是任意的
D.构造方法应该声明为void类型