计算机二级

第1221题

下列变量名的定义中,符合Java命名约定的是( )。

第1222题

自定义异常类的父类可以是( )。

第1223题

阅读下列程序片段:

public void test(){
    try{
        sayHello();
        System.out.println("hello");
    }catch(ArrayIndexOutOfBoundsException e){
        System.out.println("ArrayIndexOutOfBoundsException");
    }catch(Exception e){
        System.out.println("Exception");
    }finally{
        System.out.println("finally");
    }
}

如果sayHello()方法正常运行,则test()方法的运行结果将是( )。

第1224题

为使Java程序独立于平台,Java虚拟机把字节码和各个操作系统及硬件( )。

第1225题

Java中的基本数据类型int在不同的操作系统平台的字长是( )。

第1226题

String、StringBuffer都是( )类,都不能被继承。

第1227题

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

public class FindKeyWords
{
    public static void main(String[] args)
    {
        String 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 inegers,then a[i] is the ith integer in the array.";
        int arrayCount=0;
        int index=-1;
        String arrayStr="array";
        index=text.indexOf(arrayCount);
        while(index ______ 0)
        {
            ++arrayCount;
            index+=arrayStr.length();
            index=text.indexOf(arrayStr,index);
        }
        System.out.println("the text contains"+arrayCount+"arrays");
    }
}
第1228题

构造方法名必须与( )相同,它没有返回值,用户不能直接调用它,只能通过new调用。

第1229题

在多线程并发程序设计中,能够给对象X加锁的语句是( )。

第1230题

Java中类ObjectOutputStream支持对象的写操作,这是一种字节流,它的直接父类是( )。

第1231题

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

import java.io.*;
public class ObjectStreamTest{
    public static void main(String[] args)throws IOException{
        ObjectOutputStream oos=new ObjectOutputStream(new FileOutputStream("serial.bin"));
        java.util.Date d=new java.util.Date();
        oos.______;
        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 cnfe){
            System.out.println("class not found");
        }
    }
}
第1232题

Class类的对象由( )自动生成,隐藏在.class文件中,它在运行时为用户提供信息。

第1233题

在Java中,实现用户界面功能的包是( )。

第1234题

“++”运算符的操作数个数是( )。

第1235题

在switch(expression)语句中,expression的数据类型不能是( )。

第1236题

下列叙述中,错误的是( )。

第1237题

已知:int a[]=new int[100];在下列给出的数组元素中,非法的是( )。

第1238题

下列叙述中正确的是( )。

第1239题

支持子程序调用的数据结构是( )。

第1240题

某二叉树有5个度为2的结点,则该二叉树中的叶子结点数是( )。