( 34 )在下列程序的空白处,应填入的正确选项是Import java.io.*;Pulilc class ObjectStreamTest{Publilc static void main(string args[]) throws IOException{ObjectOutputStream s= new ObjectOutputStream(new FileOutputStream( “ serial.bin ” ));Java .util.Date d= new Java.util.Date();Oos___________ (d);ObjectInputStream is=new ObjectInputStream(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 ” );}}A ) WriterObjectB ) WriterC )BufferedWriterD ) WriterObject

( 34 )在下列程序的空白处,应填入的正确选项是

Import java.io.*;

Pulilc class ObjectStreamTest{

Publilc static void main(string args[]) throws IOException{

ObjectOutputStream s= new ObjectOutputStream

(new FileOutputStream( “ serial.bin ” ));

Java .util.Date d= new Java.util.Date();

Oos___________ (d);

ObjectInputStream is=

new ObjectInputStream(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 ” );

}

A ) WriterObject

B ) Writer

C )BufferedWriter

D ) WriterObject


相关考题:

2下列程序实现对ZIP 文件file.zip 的检索,在横线处填入正确的语句是( )。package test;import java.io.*;import java.util.*; import java.util.zip.*;public class Exam{ public static void main(String[] args){ try{ FileInputStream fis = new FilelnputStream("test/file.zip"); ZipInputStream zis = new ZiplnputStream(fis); ZipEntry en; while ((______ )!= null){ en.getName(); zis.closeEntry(); } zis.close(); } catch(Exception e){ e.pfintStackTrace(); }}A.en = zis. getNextEntry()B.en == zis.getNextEntry(C.en=zis. getEntry()D.zis.getNextEntry()

下列Java源程序结构中前三种语句的次序,正确的是A.import, package, public classB.import必为首,其他不限C.public class, import, packageD.package, import, public class

在下面Java Applet程序的下画线处填入代码,使程序完整并能够正确运行。import java.applet.*;import java.awt.*;public class HelloWorld ______ {public void paint(Graphics g) {g.drawString("Hello World!",25,25);}}

阅读下面程序import java.io.*;public class ByteStream Test{public static void main(String[] a){int[] myArray = {10,20.30,40};try{DataOutputStream dos = new DataOutputStream(new _________________( " ints.dat " ));for (int i=0;imyArray.length;i++)dos.writeInt(myArray[i] ) ;dos.close();S ystem.out.println( " Have written binary file ints.dat " );}catch (IOException ioc){System.out.println( " IO Exception " );}}}为保证程序正确运行,在程序中下划线处应填入的代码是A)FileOutputStreamB)ByteArrayOutputStreamC)BufferedOutputStreamD)FileWriter

在Java Applet程序中,如果对发生的事件做出响应和处理的时候,应该使用下列哪个语句A.import java.awt.event.*;B.import java.io.*;C.import java.awt.*;D.import java.applet.*;

( 20 )在下列程序的空白处,应填入的正确选项是import java.io.*;Public class writeInt{Public static void main(string[ ] a) {Int[ ] myArray = {10,20,30,40};try{DataOutputSystem dos= new DataOutputSystem( new FileOutputSystem( “ ints.dat ” ) ) ;for ( int i=0 ; ImyArray.length ; i++ )dos 。 writeInt ( myArray[i] ) ;dos.System.out.println( “ Have written binary file ints.dat ” );}Catch(IOException ioe){ System.out.println( “ IO Exception ” );}}}A)start( )B)close( )C)read( )D)write( )

下列程序实现对ZIP文件filel4.zip的检索,在横线处填入正确的语句。 package ch1; import java.io.*; import java.util.*; import java.util.zip.*; public class exl4 { publio static void main(String[] args} { try { FileInputStream fis = new FileInputStream("chl/filel4.zip"); ZipInputStream zis = new zipInputStream(fis); ZipEntry en; while((______) ! = null) { en.getName(); zis.clcseEntry(); } zis.close(); } catch(Exception e) { e.printStackTrace(); } } }A.en = zis.getNexTEnTRY()B.en = zis.getEntry()C.en=zis.getNextEntry()D.zis.getNextEntry()

下列哪个选项的java源文件代码片段是不正确的?A.package testpackage; public class Test{ }B.import java. io. *; package testpaekage; public class Test { }C.import java.io.*; class Person { } public class Test { }D.import java.io.*; import java. awt.*; public class Test{ }

下列( )选项的java源文件代码片段是不正确的。A.package testpackage; publicClass Test{}B.import java.io.*; package testpackage: publicClass Test{}C.import java.io.*; Class Person{} publicClass Test{}D.import java.io.*; import java.awt.*; publicClass Test{}

下列程序将类C15的对象写入文件filetxt,选择正确的语句填入下列程序的横线处。 package ch2; import java.util.*; import java.io.*; class C15______ { public iht a; public void setInt(int newa) { a = newa; } } public class Testl5 { pulibc static void main(String[] args) { C15 bj = new C15(); try { FileOutputStream fos =newFileOutputStream("ch2\\filel5.txt"); ObjectOutputStream os = ObjectOutputStream(fos); Obj.setInt(10); oos.writeObject(obj); oos.close (); fos.close(); } catch(IOException ioe) { ioe.printStackTrace(); } } }A.implements RunnableB.implements SedalizableC.extends SerializableD.implements InputStream

阅读下面Applet程序 import javax. swing. *; import java. awt. *; public class SwintgApplet extends JApplet{ JLabel 1=new JLabel("This is a Swing Applet."); public void init(){ ________________________________ } } 在程序下画线处填入正确的选项是A.Container contentPane=getContenPane(); cotentPane. add(1);B.JPanel comtenPane=new Jpane(); contentPane. add(1);C.contentPane. add(1);D.add(1);

下列代码的输出结果是( )。class parent{void printme(){System.out.println("parent");}}class child extends parent{void printme(){System. out.println("child");}void printall(){super, printme();this.printme();printme();}}public class test{public static void main(String args[]){child myc=new child();myc.printall();}}A.import java.awt.*;B.import java.applet.applet;C.import java.io.*;D.import java, awt.graphics;

在Java Applet程序中,如果对所发生的事件做出响应和处理,应该使用下列哪一条语句?A.import java.awt.event.*;B.import java.io.*;C.import java.awt.*;D.import java.applet.*;

在下列程序的空白处,应填入的正确选项是( )。A.start( )B.close( )C.read( )D.write( )

下列程序的功能是统计字符串中“array”的个数,在程序的空白处应填入的正确选项是( )。A.B.=C.=D.=

在下列程序的空白处,应填入的正确选项是( )。A.WriterObjectB.WriterC.BufferedWriterD.writerObject

下列哪个选项的java源文件程序段是不正确的? ( )A.package testpackage; public class Test{ }B.import java.io.*; package testpackage; public class Test{ }C.import java.i.*; class Person{} public class Test{ }D.import java.io.*; import java.awt.*; public class Test { }

阅读下面写文件的程序 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.myArrayB.dosC.ioeD.ints

阅读下面Applet程序 import javax.swing.*: import java.awt.*: public Class Test SwingApplet extends JApplet { JLabel 1=new JLabel("This is a Swing Applet."); public void init() { ______ } } 程序中下画线处应填入的正确选项是A.Container contentPane=getContentPane();contentPane.add(1);B.Jpanel contentPane=new JPanel();contentPane.add(1);C.contentPane.add(1);D.add(1);

在下列程序的空白处,应填入的正确选项是( )。 Import java.io.*; Pulilc class ObjectStreamTest{ Publilc static void main(string args[])throws IOEx- ception{ OhiectOutputStream os=new OhjectOutputStream (new FileOutputStream("serial.bin")); Java.util.Date d=new Java.util.Date; Oos (d); ObjectInputStream is= 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"); } }A.WriterObjectB.WriterC.BufferedWriterD.writerObject

下列程序实现对ZIP文件file.zip的检索,在横线处填入正确的语句 package test; import java.io.*: import java.util.*; import java.util.zip.*; public class Exam { public static void main(String[])args){ try{ FileInputStream fis=new FileInputStream("test/file.zip"); ZipInputStreamzis=new ZipInputStream(fis); ZipEntry en; while ((_____)!=null){ en.getName(); zis.closeEntry(); } zis.close(); } catch(Exception e) { e.printStackTrace(); } } }A.en = zis.getNextEntry()B.en = zis.getNextEntry()C.en = zis.getEntry()D.zis.getNextEntry()

请在下划线处填入代码,使程序能够正确运行。import java .awt.*;import java .applet.*;public class SayHi extends Applet{public void【 】(Graphics g){g .drawString(“Hi!”20,20);}}

( 8 )在下列 Java applet 程序的横线处填入代码,使程序完整并能够正确运行。Import java. awt. *;Import java. applet. *;Public class Greeting extends applet{Public void 【 8 】 (Graphics g) {g.drawSting( “ how are you! ” ,10,10);}}

( 20 ) 下列程序的功能是将一个整数数组写入二进制文件 。 在程序的下划线处应填入的选项是import java.io.*;public class XieShuzu{public static void main(String[] a){int [] myArray={10,20,30,40};try{DataOutputStream dos=new DataOutputStream(new FileOutputStream( " ints.dat " ));for(int i=0;imyArray.lenth;i++)dos. _______(myArray[i]);dos.close();System.out.println( " 已 经 将 整 数 数 组 写 入 二 进 制 文 件 :ints.dat " );}catch(IOException ioe){System.out.println( " IO Exception " );}}}A ) writeArrayB ) writeByteC ) writeIntD ) writeDouble

一个程序中,package、import、和class的排放次序是()A、package、import、classB、import、package、classC、三者任意D、class在最后,import、package排放次序任意

在单一文件中import、class和package的正确出现顺序是()A、package,import,classB、class,import,packageC、import,package,classD、package,class,import

单选题在下列程序的空白处,应填入的正确选项是(  )。import java.io.*;public class ObjectStreamTest{public static void main(string args[])throws IOException{ ObjectOutputStream oos=new ObjectOutputStream(new FileOutputStream("serial.bin")); Java.until.Date d=new Java.until.Date(); oos.______(); ObjectInputStream ois=new ObjectlnputStream(new FileOutputStream("serial.bin")); try{ java.until.date restoredDate=(Java.until.Date)ois.readObject(); System.out.println("read object back from serial.bin file:"+restoredDate); } catch(ClassNotFoundException cnf){ System.out.println("class not found"); }}AreadObjectBWriterCBufferedWriterDwriteObject