B)CLOSE( ) C)READ( ) SYSTEM.OUT.PRINTLN(“IO EXCEPTION”);
D)write( ) (21)在一个线程中调用下列方法,不会改变该线程运行状态的是 A)yield 方法 B)另一个线程的 join 方法 C)sleep 方法 D)一个对象的 notify 方法 (22)在关闭浏览器时调用,能够彻底终止 Applet 并释放该 Applet 所有资源的方法 是 A)stop( ) B)destroy( ) C)paint( ) D)start( ) (23)为了将 HelloApplet(主类名为 HelloApplet.class)嵌入在 greeting.html 文件中, 应该在下列 greeting.html 文件的横线处填入的代码是
A)HelloApplet.class B)CODE=” HelloApplet.class” C)CODE=” HelloApplet.class” WIDTH=150 HEIGHT=25 D)CODE=” HelloApplet.class” WIDTH=10 HEIGHT=10 (24)下列变量名的定义中,符合 Java 命名约定的是 A)fieldname B)super C)Intnum D)$number
(25)自定义异常类的父类可以是 A)Error B)VirtuaMachineError C)Exception D)Thread (26)阅读下列程序片段 Public void test(){ Try{ sayHello(); system.out.println(“hello”); } catch (ArrayIndexOutOfBoundException e) { System.out.println(“ArrayIndexOutOfBoundException”); }catch(Exception e){ System.out.println(“Exception”); }finally { System.out.println(“finally”); } } 如果 sayHello( )方法正常运行,则 test( )方法的运行结果将是 A)Hello B)ArrayIndexOutOfBondsException C)Exception Finally D)Hello Finally (27)为使 Java 程序独立于平台,Java 虚拟机把字节码与各个操作系统及硬件 A)分开 B)结合 C)联系 D)融合 (28)Java 中的基本数据类型 int 在不同的操作系统平台的字长是 A)不同的 B)32 位 C)64 位
D)16 位 (29)String、StingBuffer 都是______类,都不能被继承。 A)static B
)abstract C)final D)private (30)下列
程序的功能是统计字符串中“array”的个数,在程序的空白处应填入的正确 选项是 public class FindKeyWords{ public static void main(sring[] args){ sting text= “ An array is a data structur that stores a collection of” + “values of the same type . You access each individual value” + “through an integer index . For example,if a is an array” + “of inergers, then a[i] is the ith integer in the array.”; Int arrayCount =0; Int idex = -1; Sting arrarStr =”array”; Index = text.indexof(arrayStr); While(index ++arrayCount; Index += arrayStr.length(); Index = text.indexof(arrayStr,index); } System.out.println (“the text contains” + arrayCount + “arrays”); } } A)< B)= C)<= D)>= (31)构造方法名必须与______相同,它没有返回值,用户不能直接调用它,只 能通过 new 调用。 A)类名 0) {
B)对象名 C)包名 D)变量名 (32)在多线程并发程序设计中,能够给对象 x 加锁的语句是 A)x.wait( ) B)synchronized(x) C)x.notify( ) D)x.synchronized( ) (33)Java 中类 ObjectOutputStream 支持对象的写操作,这是一种字节流,它的直 接父类是 A)Writer B)DataOutput C)OutputStream D)ObjectOutput (34)在下列程序的空白处,应填入的正确选项是 Import java.io.*; Pulilc class ObjectStreamTest{ Publilc static void main(string args[]) throws IOException{ ObjectOutputStream oos= new ObjectOutputStream (new FileOutputStream(“serial.bin”)); Java.util.Date d= new Java.util.Date(); Oos (d);
ObjectInputStream ois= 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 c