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

上传人:b****1 文档编号:14985896 上传时间:2023-06-29 格式:DOCX 页数:77 大小:35.35KB
下载 相关 举报
精编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.创建一个只能存放String的泛型ArrayList的语句是哪项?

答案:

B

A.ArrayListal=newArrayList();

B.ArrayListal=newArrayList();

C.ArrayListal=newArrayList();

D.ArrayListal=newList();

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

选择所有的正确答案。

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

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

答案:

A.absolute()

B.log()

C.cosine()

D.sine()

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

答案:

B

A.squareRoot()

B.sqrt()

C.root()

D.sqr()

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

答案:

D

A.-0.12和0.56E3

B.0.12和1.1E1

C.-23.45和0.0

D.0.356和0.03

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

publicclassExample{

publicstaticvoidmain(String[]args){

System.out.println(Math.round(Float.MAX_VALUE));

}

}"

答案:

B

A.输出Integer.MAX_VALUE

B.输出一个最接近Float.MAX_VALUE的整数

C.编译失败

D.运行时输出异常信息

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

publicclassExample{

publicstaticvoidmain(String[]args){

doubled1=-0.5;

System.out.println(""Ceild1=""+Math.ceil(d1));

System.out.println(""Floord1=""+Math.floor(d1));

}

}

"

答案:

B

A.输出Ceild1=-0.0Floord1=-1.0

B.输出Ceild1=0.0Floord1=-1.0

C.输出Ceild1=-0.0Floord1=-0.0

D.输出Ceild1=0.0Floord1=0.0

8."给出以下代码,请问在程序的第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]));

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

publicclassExample{

publicstaticvoidmain(String[]args){

System.out.println(Math.min(Float.NaN,Float.POSITIVE_INFINITY));

}

}"

答案:

A

A.输出NaN

B.打印输出Infinity

C.运行时异常,因为NaN不是有效的参数

D.运行时异常,因为Infinity不是有效的参数

10.下列哪些项是泛型的优点?

答案:

A

A.不用向下强制类型转换

B.代码容易编写

C.类型安全

D.运行速度快

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

答案:

A.reader不是FileReader或者BufferedReader类型

B.reader可以使FileReader或者BufferedReader

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

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

12.List接口的特点是哪项?

答案:

C

A.不允许重复元素,元素有顺序

B.允许重复元素,元素无顺序

C.允许重复元素,元素有顺序

D.不允许重复元素,元素无顺序

13."以下代码执行结果是什么?

classExample{

publicstaticStringoutput="""";

publicstaticvoidfoo(inti){

try{

if(i==1){

thrownewException();

}

output+=""1"";

}catch(Exceptione){

output+=""2"";

return;

}finally{

output+=""3"";

}

output+=""4"";

}

publicstaticvoidmain(String[]args)throwsIOException{

foo(0);

foo

(1);

System.out.println(output);

}

}"

答案:

A.无内容输出

B.代码编译失败

C.输出13423

D.输出14323

14."下列代码执行后的输出是哪项?

publicclassExample{

publicstaticvoidmain(String[]args){

Listal=newArrayList();

al.add(""1"");

al.add(""2"");

al.add(""2"");

al.add(""3"");

System.out.println(al);

}

}"

答案:

A.[1,2,3]

B.[1,2,3,3]

C.[1,2,2,3]

D.[2,1,3,2]

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

publicclassExample{

publicstaticvoidmain(String[]args){

TreeSett=newTreeSet();

if(t.add(""one""))

if(t.add(""two""))

if(t.add(""three""))

t.add(""four"");

for(Strings:

t){

System.out.print(s);

}

}

}"

答案:

D

A.one

B.onethreetwo

C.onetwothreefour

D.fouronethreetwo

16."现有:

publicclassExample{

publicstaticvoidmain(String[]args){

TreeSets=newTreeSet();

s.add(""one"");

s.add(""two"");

//插入代码处

for(Strings2:

sorted){

System.out.print(s2+"""");

}

}

}

和四个代码片段:

s1:

SortedSetsorted=s.tailSet(s.first());

s2:

SortedSetsorted=s.tailSet(s.first());

s3:

SortedSetsorted=(SortedSet)s.tailSet(s.first());

s4:

SortedSetsorted=(SortSet)s.tailSet(s.first());

分别插入到插入代码处,哪项可以编译?

"

答案:

A.S2

B.S2和S3

C.S2和S4

D.S2、S3和S4

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

答案:

D

A.Mapm=newMap();

B.Mapm=newMap(initcapacity,incrementcapacity);

C.Mapm=newMap(newCollection());

D.以上都不对

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."以下代码的执行结果是?

publicclassExample{

publicstaticvoidmain(String[]args){

Filef=newFile(""c:

\\large.txt"");

}

}"

答案:

A.large.txt文件在本地硬盘上被创建

B.在Unix系统上运行失败,因为路径分割符不正确

C.large.txt文件在本地硬盘上没有被创建

D.如果large.txt文件已经存在,则一个异常被抛出

21.以下说法正确的是()

答案:

A.RandomAccessFile类是File类的子类

B.FileWriter类提供有操作基本数据类型的方法

C.RandomAccessFile类提供有删除磁盘文件的方法

D.File类提供有删除磁盘文件的方法

22.以下有关java.lang.Exception异常类的正确描述有?

答案:

B

A.该类是一个公共类

B.该类是Throwable类的子类

C.该类实现了Throwable接口

D.该类可以序列化

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

答案:

B

A.Collection

B.List

C.Map

D.Set

24."现有如下代码:

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){

25.为了保证方法的线程安全,声明方法的时候必须使用哪个修饰符?

答案:

A.new

B.transient

C.void

D.synchronized

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

publicclassExample{

publicstaticvoidmain(String[]args){

try{

doublex=64.0;

doubley=0.0;

System.out.println(x%y==x%y);

}catch(Exceptione){

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

}

}

}"

答案:

D

A.编译失败

B.运行时抛出异常

C.打印输出true

D.打印输出false

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

publicclassExample{

publicstaticvoidmain(String[]args){

try{

System.out.println(Float.NaN==Float.NaN);

System.out.println(Float.POSITIVE_INFINITY==Float.POSITIVE_INFINITY);

}catch(Exceptione){

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

}

}"

答案:

D

A.输出+G20:

J20falsefalse

B.输出Exception

C.输出truetrue

D.输出falsetrue

28.下列属于非受检异常(运行时异常)的是哪项?

答案:

A

A.IOException

B.NullPointerException

C.OutOfMemoryError

D.

29.以下说法错误的是?

答案:

C

A.Java中接口不能被private或Protected修饰符修饰

B.Java中一个类可以实现多个接口,但是只能继承一个父类

C.接口中定义的成员变量,即使不说明,默认均是public\static\final的

D.final\static\native关键字不能修饰接口,

30.请问以下哪个程序代码体现了对象之间的isa关系?

答案:

A."publicinterfaceColor{

}

publicclassShape{

privateColorcolor;

}"

B."publicinterfaceComponent{

}

publicclassCpmtaomerimplementsComponent{

privateComponent[]children;

}"

C."publicclassSpecies{

}

publicclassAnimal{

privateSpeciesspecies;

}"

D."publicclassAnimal{

publicinterfaceSpecies{

}

privateSpeciesspecies;

}"

31."给出以下代码,改程序的执行结果是?

interfaceBase{

intk=0;

}

publicclassExampleimplementsBase{

publicstaticvoidmain(String[]args){

inti;

Exampleexm=newExample();

i=exm.k;

i=Example.k;

i=Base.k;

System.out.println(i);

}

}"

答案:

D

A.无内容输出

B.代码编译失败

C.代码运行时输出异常信息

D.打印输出0

32."现有以下代码:

interfaceW{

}

classZimplementsW{

}

classXextendsZ{

}

classYextendsZ{

}

下列哪些代码段是正确的?

"

答案:

A."Xx=newX();

Yy=newY();

Zz=newZ();

y=(Y)x;"

B."Xx=newX();

Yy=newY();

Zz=newZ();

x=(X)y;"

C."Xx=newX();

Yy=newY();

Zz=newZ();

Z=(Z)x;"

D."Xx=newX();

Yy=newY();

Zz=newZ();

Ww=(W)x;"

33."对以下两个代码片段说法正确的是?

代码片段1:

inta=3;

intb=0;

intc=a/b;

代码片段2:

floata=3.0f;

floatb=0.0f;

floatc=a/b;"

答案:

C

A.执行两端代码都会抛出异常

B.执行两段代码都无异常抛出

C.执行两段代码,只有代码片段1抛出异常

D.执行两段代码,只有代码片段2抛出异常

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

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

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

答案:

AC

A.可以有多个catch

B.只能有一个catch

C.可以没有catch

D.finally必须有

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

publicabstractclassExampleextendsBase{

publicabstractvoidmethod();

}

classBase{

publicBase()throwsIOException{

thrownewIOException();

}

}"

答案:

A.代码编译失败,因为非抽象类不能被扩展为抽象类

B.代码编译失败,因为必须提供一个可以抛出或可以不抛出IOException异常的构造器

C.代码编译失败,以in为必须提供一个可以抛出IOException异常或其子类的构造器

D.代码编译成功

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

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

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

答案:

AC

A.Throwable

B.Error

C.Exception

D.String

39."请问以下代码的直接执行结果是?

classExample{

publicstaticvoidmain(String[]args){

try{

System.out.println(args[0]);

System.out.println(""I'mnomal"");

if(true)

return;

}catch(Exceptionex){

System.out.println(""I'mexception"");

if(true)

return;

}finally{

System.out.println(""I'mfinally."");

}

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

}

}"

答案:

A

A."I'mexception

I'mfinally

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

当前位置:首页 > 表格模板 > 合同协议

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

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