CoreJava第三次内测试卷

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

《CoreJava第三次内测》

一、单选题(共33分,每题2分,共66分)

1.下列对Java中的继承描述错误的说法是()。

A.子类至少有一个基类

B.子类可作为另一个子类的基类

C.子类除了包含它直接定义的属性外,还包含其父类的私有属性

D.子类继承父类的方法访问权限保持不变

2.try {}里有一个return语句,那么紧跟在这个try后的finally {}里的代码会不会被执行,什么时候被执行?

( )

A.不会执行

B.会执行,在return前执行

C.会执行,在return后执行

D.会执行,可能在return前执行,也可能在return后执行

3.构造方法是否可被重写和重载()。

A.不能重写,可以重载

B.可以重写,不能重载

C.不能重写,不能重载

D.可以重写,可以重载

4.给出一段程序,试判断哪个是正确的结果()

public class rtExcept{

public static void throwit(){

System.out.print(“throwit”);

throw new RuntimeException(); }

public static void main(String [] aa){

try{

System.out.print(“hello “);

throwit(); }

catch(Exception re){

System.out.print(“caught ”); }

finally{

System.out.print(“finally ”); }

System.out.print(“after ”);

}

}

A、hello throwit caught

B、hello throwit caught finally after

C、hello throwit RuntimeException after

D、hello throwit caught finally after RuntimeException

5.给出一段程序,试判断哪个是正确的结果()

public class myprogram{

public static void main (String args[]){

try{

System.out.print(“Hello world ”); }

finally{

System.out.println(“Finally executing”);

}}}

A、无法编译,因为没有指定异常

B、无法编译,因为没有catch子句

C、Hello world

D、Hello world Finally executing

6.对于catch子句的排列,下列哪种是正确的( )

A.父类在先,子类在后

B.子类在先,父类在后

C.有继承关系的异常不能在同一个try程序段内

D.一个try后只能放一个catch

7.Java中,泛型数据类型声明可能出现的符号是( )

A.R

B.D

C.T

D.都可以

8.关于Java中异常的叙述正确的是:()

A.异常是程序编写过程中代码的语法错误B.异常是程序编写过程中代码的逻辑错误C.异常出现后程序的运行马上中止D.异常是可以捕获和处理的

9.所有的异常和错误皆继承哪一个类?()

A.java.io.Exception B.ng. Exception

C.ng. Throwable D.ng.Error

10.下列关于try-catch-finally语句的描述中,错误的是()

A.try语句后面的程序段将给出处理异常的语句

B.catch()方法跟在try语句后面,它可以是一个或多个

C.catch()方法有一个参数,该参数是某种异常类的对象

D.finally语句后面的程序段总是被执行的,该语句起到提供统一接口的作用

11.给出下面的代码

public void test() {

try {

oneMethod();

System.out.println("condition 1");

} catch (ArrayIndexOutOfBoundsException e) {

System.out.println("condition 2");

} catch(Exception e) {

System.out.println("condition 3");

} finally {

System.out.println("finally");

}

}

在oneMethod()方法有异常的情况下不可能显示什么? [ ]

A. condition 1

B. condition 2

C. condition 3

D. finally

12.Java中的内存回收一般是由系统自动操作的,但是我们可以通过什么方法来手动回收垃圾()

A、finalize

B、final

C、finally

D、System.exit

13.泛型通配符使用的符号是:()

A .? B. * C. / D.~

14.下面代码要将一段字符串循环增加5000次,请选择正确高效的代码()

A.String temp=”abcdefg”String str=””;

for(int i=0;i<5000;i++){

str+=temp;

}

B.String temp=”abcdefg”StringBuffer sb=new StringBuffer();

for(int i=0;i<5000;i++){

sb.append(temp);

}

C. String temp=”abcdefg”StringBuffer sb=new StringBuffer();

for(int i=0;i<5000;i++){

sb+=temp;

}

D.String temp=”abcdefg”StringBuffer sb=””;

for(int i=0;i<5000;i++){

sb+=temp;

}

15.通过Math类获得一个随机值,下面语句正确的是()

A、Math m=new Math(); int i=m.random();

B、int i=Math.random();

C、double d=Math.random();

D、Math m=new Math(); double d

=m.random();

16.通过Random类产生一个0-24之间的随机数,则正确的是()

A.int i=Random.nextInt();

B.int i=Random.nextInt(25);

C.Random r=new Random(); int i=r.nextInt();

D.Random r=new Random(); int i=r.nextInt(25);

17.SimpleDateFormat可以用来将Date对象格式化成各种字符串,能够将日期Date d转换为“2012-08-01”

格式的语句是()

A.SimpleDateFormat sdf=new SimpleDateFormat(“yyyy-MM-dd”);

sdf.format(d);

B.SimpleDateFormat sdf=new SimpleDateFormat(“yyyy-MM-dd”);

sdf.parse(d);

C.SimpleDateFormat sdf=new SimpleDateFormat(“yyyy-mm-dd”);

sdf.parse(d);

D.SimpleDateFormat sdf=new SimpleDateFormat(“yyyy-mm-dd”);

sdf. format (d);

18.关于捕捉异常是用的try catch语句,下面写法正确的是()

A、try{}catch{}

B、try{}catch(){}

C、try{}catch(Exception e){}

D、try{}catch(Exception ){}

19.下列异常当中,不属于运行时异常的是( C )

A. NullPointerException B、IndexOutOfBoundsException

相关文档
最新文档