精选新版JAVASE综合测试版题库188题含参考答案.docx

上传人:b****2 文档编号:1059008 上传时间:2023-04-30 格式:DOCX 页数:77 大小:34.36KB
下载 相关 举报
精选新版JAVASE综合测试版题库188题含参考答案.docx_第1页
第1页 / 共77页
精选新版JAVASE综合测试版题库188题含参考答案.docx_第2页
第2页 / 共77页
精选新版JAVASE综合测试版题库188题含参考答案.docx_第3页
第3页 / 共77页
精选新版JAVASE综合测试版题库188题含参考答案.docx_第4页
第4页 / 共77页
精选新版JAVASE综合测试版题库188题含参考答案.docx_第5页
第5页 / 共77页
精选新版JAVASE综合测试版题库188题含参考答案.docx_第6页
第6页 / 共77页
精选新版JAVASE综合测试版题库188题含参考答案.docx_第7页
第7页 / 共77页
精选新版JAVASE综合测试版题库188题含参考答案.docx_第8页
第8页 / 共77页
精选新版JAVASE综合测试版题库188题含参考答案.docx_第9页
第9页 / 共77页
精选新版JAVASE综合测试版题库188题含参考答案.docx_第10页
第10页 / 共77页
精选新版JAVASE综合测试版题库188题含参考答案.docx_第11页
第11页 / 共77页
精选新版JAVASE综合测试版题库188题含参考答案.docx_第12页
第12页 / 共77页
精选新版JAVASE综合测试版题库188题含参考答案.docx_第13页
第13页 / 共77页
精选新版JAVASE综合测试版题库188题含参考答案.docx_第14页
第14页 / 共77页
精选新版JAVASE综合测试版题库188题含参考答案.docx_第15页
第15页 / 共77页
精选新版JAVASE综合测试版题库188题含参考答案.docx_第16页
第16页 / 共77页
精选新版JAVASE综合测试版题库188题含参考答案.docx_第17页
第17页 / 共77页
精选新版JAVASE综合测试版题库188题含参考答案.docx_第18页
第18页 / 共77页
精选新版JAVASE综合测试版题库188题含参考答案.docx_第19页
第19页 / 共77页
精选新版JAVASE综合测试版题库188题含参考答案.docx_第20页
第20页 / 共77页
亲,该文档总共77页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

精选新版JAVASE综合测试版题库188题含参考答案.docx

《精选新版JAVASE综合测试版题库188题含参考答案.docx》由会员分享,可在线阅读,更多相关《精选新版JAVASE综合测试版题库188题含参考答案.docx(77页珍藏版)》请在冰点文库上搜索。

精选新版JAVASE综合测试版题库188题含参考答案.docx

精选新版JAVASE综合测试版题库188题含参考答案

2020年JAVASE综合考试试题库188题[含答案]

一、选择题

1.表示键值对概念的接口是哪项?

答案:

D

A.Set

B.List

C.Collection

D.Map

2.Java语言中异常的分类是哪项?

答案:

A.运行时异常和异常

B.受检异常和非受检异常

C.错误和异常

D.错误和运行时异常

3.以下哪个方法是Math类中定义的?

答案:

A.absolute()

B.log()

C.cosine()

D.sine()

4.定义在Math类上的round(doubled)方法的返回值类型是什么?

答案:

A.char

B.int

C.long

D.double

5.以下哪个方法用于计算平方根?

答案:

B

A.squareRoot()

B.sqrt()

C.root()

D.sqr()

6.调用Math.random()方法最有可能输出以下哪些结果?

答案:

D

A.-0.12和0.56E3

B.0.12和1.1E1

C.-23.45和0.0

D.0.356和0.03

7."以下代码的运行结果是什么?

publicclassExample{

publicstaticvoidmain(String[]args){

System.out.println(Math.min(0.0,-0.0));

}

}"

答案:

C

A.代码编译失败

B.输出0.0

C.输出-0.0

D.代码编译成功,但运行时输出异常信息

8."给出以下代码,为了结果输出-12.0,方法method(d)应为以下哪个方法?

publicclassExample{

publicstaticvoidmain(String[]args){

doubled=-11.1;

doubled1=method(d);

System.out.println(d1);

}

}"

答案:

A

A.floor()

B.ceil()

C.round()

D.abs()

9."给出以下代码,请问在程序的第6行插入那条语句,改程序可依次打印输出11、10、9?

1.publicclassExample{

2.publicstaticvoidmain(String[]args){

3.doublex[]={10.2,9.1,8.7};

4.inti[]=newint[3];

5.for(inta=0;a

6.

7.System.out.println(i[a]);

8.}

9.}

10.}"

答案:

C

A.i[1]=((int)Math.min(x[a]));

B.i[1]=((int)Math.max(x[a]));

C.i[1]=((int)Math.ceil(x[a]));

D.i[1]=((int)Math.floor(x[a]));

10.以下哪些是Collection接口的子接口?

答案:

BD

A.Dictionary

B.List

C.Map

D.Set

11.以下哪些是定义在java.io包中的抽象类?

答案:

A.InputStream

B.PrintStream

C.Reader

D.FileInputStream

12.以下哪些集合接口支持重复元素存在?

答案:

B

A.Collection

B.List

C.Map

D.Set

13."现有如下代码:

publicclassExample{

publicstaticvoidmain(String[]args){

try{

System.out.println(""before"");

doRisyThing();

System.out.println(""after"");

}catch(Exceptione){

System.out.println(""catch"");

}

System.out.println(""done"");

}

publicstaticvoiddoRisyThing()throwsException{

//thiscodereturnsunlessitthrowsanException

}

}

该代码可能的执行结果有哪些?

"

答案:

A.beforecatch

B.beforeafterdone

C.beforecatchdone

D.beforeaftercatch

14.欲构造ArrayList类继承了List接口,下列哪个方法是正确的?

答案:

B

A.ArrayListmyList=newObject()

B.ListmyList=newArrayList()

C.ArrayListmyList=newList()

D.ListmyList=newList()

15."现有:

list是一个合法的集合引用

getCollection()返回一个合法集合的引用,以下语句哪些是合法的?

"

答案:

C

A.for(Objecto:

list)

B.for(Objecto:

getCollection())

C.for(Objecto:

list.iterator())

D.for(IteratorI;list.iterator();i.hasNext())

16.以下哪些语句用于创建一个Map实例?

答案:

D

A.Mapm=newMap();

B.Mapm=newMap(initcapacity,incrementcapacity);

C.Mapm=newMap(newCollection());

D.以上都不对

17."以下代码执行结果是?

publicclassExample{

publicstaticvoidmain(String[]args){

TreeMapmap=newTreeMap();

map.put(""one"",""1"");

map.put(""two"",""2"");

map.put(""three"",""3"");

displayMap(map);

}

staticvoiddisplayMap(TreeMapmap){

Collectionc=map.entrySet();

Iteratori=c.iterator();

while(i.hasNext()){

Objecto=i.next();

System.out.print(o.toString());

}

}

}"

答案:

A.onetwothree

B.123

C.one=1three=3two=2

D.onethreetwo

18."现有如下类型:

a-java.util.Hashtable

b-java.util.List

c-java.util.ArrayList

d-java.util.SortedSet

和定义:

1-使用本接口,允许用户控制集合中每个元素的插入位置

2-使用本集合,确保用户可以按照递增或元素的自然顺序遍历集合

3-本具体类型允许空元素及基于索引的访问

4-本集合是同步的

哪一组匹配是对的?

"

答案:

A.2描述d,3描述b

B.1描述b,3描述c

C.3描述a,4描述b

D.4描述a,2描述c

19."现有:

publicclassExample{

publicstaticvoidmain(String[]args){

//插入代码处

c.put(""X"",123);

}

}

下列哪些插入到插入代码处能够正常编译?

"

答案:

A.Mapc=newSortedMap();

B.HashMapc=newHashMap();

C.SortedMapc=newTreeMap();

D.Mapc=newLinkedHashMap();

20.以下哪些类提供了创建一个目录的方法?

答案:

A

A.File

B.DataOutput

C.Directory

D.FileDescriptor

21.现有intx=reader.read(),下列哪一项正确?

答案:

A.reader不是FileReader或者BufferedReader类型

B.reader可以使FileReader或者BufferedReader

C.reader可以使FileReader类型,但不能使BufferedReader类型

D.reader可以使BufferedReader类型,但不能使FileReader类型

22."现有代码:

publicclassExample{

publicstaticvoidmain(String[]args){

try{

System.out.print(Integer.parseInt(""forty""));

}catch(RuntimeExceptione){

System.out.println(""Runtime"");

}catch(NumberFormatExceptione){

System.out.println(""Number"");

}

}

}

执行结果是什么?

"

答案:

C

A.输出Number

B.输出Runtime

C.输出40

D.编译失败

23.以下哪些有关Vector类的描述是正确的?

答案:

C

A.该类是个public类

B.该类是个final类

C.该类实现了List接口

D.该类可以序列化

24.假设有自定义异常类ServiceException,那么抛出该异常的语句正确的是哪项?

答案:

C

A.raiseServiceException

B.thrownewServiceException()

C.throwServiceException

D.throwsServiceException

25.以下哪些方法在Class类中定义?

答案:

A.getConstructors()

B.getPrivateMethods()

C.getDeclaredFields()

D.getImports()

 

26."下列代码执行后的结果是?

publicclassExample{

publicstaticvoidmain(String[]args){

try{

doublex=64.0;

doubley=0.0;

System.out.println(x%y);

}catch(Exceptione){

System.out.println(""Exception"");

}

}

}"

答案:

D

A.编译失败

B.输出Exception

C.输出Infinity

D.输出NaN

27."关于以下代码,说法正确的是?

classExample{

publicstaticvoidmain(String[]args)throwsIOException{

System.out.println(""BeforeTry"");

try{

}catch(Throwablee){

System.out.println(""InsideCatch"");

}

System.out.println(""AttheEnd"");

}

}"

答案:

B

A.代码编译失败,因为无异常抛出

B.代码编译失败,因为未导入IOException异常类

C."输出BeforeTry

AttheEnd"

D."输出InsideCatch

AttheEnd"

28.关于try…catch…finally结构,描述正确的是些?

答案:

AC

A.可以有多个catch

B.只能有一个catch

C.可以没有catch

D.finally必须有

29."当fragile()方法抛出一个IllegalArgumentException异常时,下列代码的运行结果是什么?

publicstaticvoidmain(String[]args)throwsIOException{

try{

fragile();

}catch(NullPointerExceptione){

System.out.println(""NullPointerExceptionthrown"");

}catch(Exceptione){

System.out.println(""Exceptionthrown"");

}finally{

System.out.println(""Donewithexceptions"");

}

System.out.println(""myMethodisdone"");

}

}"

答案:

A.输出NullPointerExceptionthrown

B.输出Exceptionthrown

C.输出DonewithException

D.输出myMethodisdone

30."现有如下代码:

publicclassExample{

publicstaticvoidmain(String[]args){

try{

intx=Integer.parseInt(""42a"");

//插入代码处

System.out.println(""oops"");

}

}

}

在插入代码处插入哪些语句可以在运行后输出oops?

"

答案:

C

A.}catch(IllegalArgumentExceptione){(非法参数异常)

B.}catch(IllegalStateExceptionc){

C.}catch(NumbelFormatExceptionn){

D.}catch(ClassCastExceptionc){

31."下列代码的执行结果是?

classExample{

publicstaticvoidmain(String[]args)throwsIOException{

inti=1,j=1;

try{

i++;

j--;

if(i==j){

j++;

}

}catch(ArithmeticExceptione){

System.out.println(0);

}catch(ArrayIndexOutOfBoundsExceptione){

System.out.println

(1);

}catch(Exceptione){

System.out.println

(2);

}finally{

System.out.println(3);

}

System.out.println(4);

}

}"

答案:

CD

A.输出1

B.输出2

C.输出3

D.输出4

32.以下哪些是catch语句能够捕获处理的异常?

答案:

AC

A.Throwable

B.Error

C.Exception

D.String

33.以下哪些描述是正确的?

答案:

CD

A.try语句块后必须至少存在一个catch语句块

B.try语句块后可以存在不限数量的finally语句块

C.try语句块后必须至少存在一个catch语句块或finally语句块

D.如果catch和finally语句块同时存在,则catch语句块必须位于finally语句块前

34."以下代码的输出结果是什么?

选择所有的正确答案。

classExample{

publicstaticvoidmain(String[]args)throwsIOException{

for(inti=0;i<10;i++){

try{

try{

if(i%3==0)

thrownewException(""E0"");

System.out.println(i);break;

}catch(Exceptioninner){

i*=2;

if(i%3==0)

thrownewException(""E1"");

}finally{

++i;

}

}catch(Exceptionouter){

i+=3;

}finally{

--i;

}

}

}

}"

答案:

A.4

B.5

C.6

D.7

35."下列代码的运行结果是?

classExample{

publicstaticvoidmain(String[]args)throwsIOException{

try{

return;

}finally{

System.out.println(""Finally"");

}

}

}"

答案:

B

A.无内容输出

B.输出Finally

C.代码编译失败

D.输出异常信息

36."下列代码的执行结果是?

classExample{

privatevoidmethod1()throwsException{

thrownewRuntimeException();

}

publicvoidmethod2(){

try{

method1();

}catch(RuntimeExceptione){

System.out.println(""CaughtRuntimeException"");

}catch(Exceptione){

System.out.println(""CaughtException"");

}

}

publicstaticvoidmain(String[]args)throwsIOException{

Examplea=newExample();

a.method2();

}

}"

答案:

A.代码编译失败

B.输出CaughtRuntimeException

C.输出CaughtException

D.输出CaughtRuntimeException和CaughtException

37.在方法声明中,说明该方法可能会抛出的异常列表时使用哪个关键字?

答案:

D

A.throw

B.catch

C.finally

D.throws

38."如下代码执行后的输出结果是?

publicclassExample{

publicstaticvoidmain(String[]args){

try{

thrownewException();

}catch(Exceptione){

try{

thrownewException();

}catch(Exceptione2){

System.out.println(""inner"");

}

System.out.println(""middle"");

}

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

}

}"

答案:

D

A.innerouter

B.middleouter

C.innermiddleouter

D.编译失败

39."现有如下代码:

publicclassExample{

publicstaticvoidmain(String[]args){//a

newExample().topGo();

}

voidtopGo(){//b

middleGo();

}

voidmiddleGo(){//c

go();

System.out.println(""latemiddle"");

}

voidgo(){//d

thrownewException();

}

}

为了使代码能够编译通过,需要在哪个地方加入声明throwsException?

"

答案:

B

A.d

B.c和d

C.b、c和d

D.a、b、c和d

40."下面代码的执行结果是?

classExampleextendsUtils{

publicstaticvoidmain(String[]args){

try{

System.out.print(newExample().getlnt(""42""));

}catch(Exceptione){

System.out.println(""Exc"");

}

}

intgetlnt(Stringarg)throwsException{

returnInteger.parseInt(arg);

}

}

classUtils{

intgetlnt(){

return42;

}

}"

答案:

B

A.NFExc

B.42

C.42NFExc

D.编译失败

41.请问以下哪些关于try…catch…finally结构中的finally语句的描述是正确的?

答案:

C

A.只有当一个catch语句获得执行后,finally语句才获得执行

B.只有当catch语句未获得执行时,finally语句才获得执行

C.如果有finally语句,return语句将在finally语句执行完毕后才会返回

D.只有当异常抛出时,finally语句才获得执行

42."关于以下代码,说法正确的是?

classExample{

publicstaticvoidmain(String[]args)throwsIOException{

System.out.println(""BeforeTry"");

try{

}catch(java.io.IOExceptione){

System.out.println(""InsideCatch"");

}

System.out.println(""AttheEnd"");

}

}"

答案:

A.代码编译失败,因为无异常抛出

B.代码编译失

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 小学教育 > 语文

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2