下列程序实现对ZIP文件file.zip的检索,在横线处填入正确的语句( )。   package test;   importjava.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");   ZipInputStream zis=new ZiplnputStream(fis);   ZipEntry an;   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.util.*;
public class LetterASort
public static void main (String args [])
ArrayList <String> strings = new ArrayList<String> ( ) ;
strings.add("aAaA") ;
strings.add ("AaA") ;
strings.add("aAa") ;
strings.add ("AAaa") ;
Collection.sort (strings) ;
for(Stirng s:strings) System.out.print (s+" ");


输出的结果是______.

AaaaAaAaAaaAaA

在程序运行过程中,经常需要扩展数组,则应该使用java.util. 【15】 类。

下面程序段是从对象流中读取对象,请将程序补充完整。 import java.util.*; import java.io.*; public class UnSerializaDate{ Date d=null; UnSerializaDate( ){ try{ FileInputStream f=new FileInputStream("date.set"); ObjectInputStream s=new ObjectlnputStream(f); _______. f.close( ); } catch(Exception e){ e.printStackTrace( ); } } public static void main(String args[]){ UnSerializaDate a=new UnSerializaDate( ); System.out.println("The date read is:"+a.d.toString( )); } }

d=(Date)s.readObject();

下面程序实现对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"); ZipInputStream zis=new ZipInputStream(fis); ZipEntry en; while((______)!=null){ en.getName( ); zis.closeEntry( ); } Zis.close( ); }catch(Exception e){e.printStackTrace( );} } }

A:en=zigetNextEntry( ) B:en==zigetNextEntry( ) C:en=zigetEntry( ) D:zigetNextEntry( )

设有如下程序: import java.util.*; public class Sun { public static void main (String args[ ]) { int score; String a; Random r=new Random ( ); score=r.nextInt (4)+5; switch(score) { case 0: a="E"; break; case 1: a="D"; break; case 2: a="C"; break; case 3: a="B"; break; default: a="A"; } System.out.println (A) ; } } 程序运行的结果是( )。

A:a="A" B:a="E" a="A" C:a="E" D:a="C"

从对象流中读取对象,请在画线处加入代码完成此程序 【10】 。 import java.util.*; import java.io.*; public class UnSerializeDate { Date d = null; UnSerializeDate( ) { try{ FileInputStream f = new FileInputStream("data.ser"); ______; d = (Date) s.readObject( ); f.close( ); } catch(Exception e) { e.printStackTrace( ); } } public static void main(String args[ ]) { UnSerializeDate a = new UnSerializeDate( ); System.out.println("The date read is :"+a.d.toString( )); } }

ObiectInputSlieam s=new ObjectInputStream(f);

设有如下程序: import java.util.*; public class Sun { public static void main(String args[ ]) { int score; String a; Random r=new Random( ); score=r.nextInt(4)+5; switch(score) { case 0: a="E"; break; case 1: a="D"; break; case 2: a="C"; break; case 3: a="B"; break; default: a="A"; } System.out.println(A) ; } } 程序运行的结果是( )。

A:a="A" B:aa"E" a="A" C:a="E" D:a="C"

下面程序段是从对象流中读取对象,请将程序补充完整。 import java.util.*; import java.io.*; public class UnSerializaDate{ Date d=null; UnSerializaDate( ){ try{ FilelnputStream f=new FilelnputStream("date.ser"); ObjectlnputStream S=new ObjectlnputStream(f); 【13】 f.close( ); } catch(Exception e){ e.printStackTrace( ); } } public static void main(String args[]){ UnSerializaDate a=new UnSerializaDate( ); System.out.println("The date read is:"+a.d.toString( )); } )

d=(Date)s.readObject();

微信扫码获取答案解析
下载APP查看答案解析