单选题 Java
题号 #2243907

在下列程序的空白处,应填入的正确选项是(  )。
Import java.io.*;
Pulilc class ObjectStreamTest{
Publilc static void main(string args[])throws IOEx-
ception{
OhiectOutputStream oos=new OhjectOutputStream
(new FileOutputStream("serial.bin"));
Java.util.Date d=new Java.util.Date();
Oos (d);
ObjectInputStream ois=
new OhjectlnputStream(new FileOutputStream("serial.
bin"));
try{
java.util.date restoredDate=
(Java.util.Date)ois.readObject();
System.out.println
("read object back from serial.bin file:"
+restoredDate);
}
Catch(ClassNotFoundException cnf){
System.out.println("class not found");
}
}

进入在线模考

参考答案

D

答案解析

D。【解析】本题考查的是输入/输出及文件操作,writerObject方法是向数据流中写入数据。

你可能感兴趣的试题

找试题 · 找答案 · 找资料 在线模考