精选新版JAVASE综合完整题库188题含标准答案.docx

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

精选新版JAVASE综合完整题库188题含标准答案.docx

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

精选新版JAVASE综合完整题库188题含标准答案.docx

精选新版JAVASE综合完整题库188题含标准答案

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

一、选择题

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

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]

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

答案:

D

A.-0.12和0.56E3

B.0.12和1.1E1

C.-23.45和0.0

D.0.356和0.03

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

publicclassExample{

publicstaticvoidmain(String[]args){

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

}

}"

答案:

C

A.代码编译失败

B.输出0.0

C.输出-0.0

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

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

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

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

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

publicclassExample{

publicstaticvoidmain(String[]args){

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

}

}"

答案:

A

A.输出NaN

B.打印输出Infinity

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

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

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

答案:

A

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

B.代码容易编写

C.类型安全

D.运行速度快

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

答案:

BD

A.Dictionary

B.List

C.Map

D.Set

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

答案:

C

A.该类是个public类

B.该类是个final类

C.该类实现了List接口

D.该类可以序列化

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

答案:

D

A.Set

B.List

C.Collection

D.Map

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

答案:

A.reader不是FileReader或者BufferedReader类型

B.reader可以使FileReader或者BufferedReader

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

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

12.创建一个只能存放String的泛型ArrayList的语句是哪项?

答案:

B

A.ArrayListal=newArrayList();

B.ArrayListal=newArrayList();

C.ArrayListal=newArrayList();

D.ArrayListal=newList();

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

答案:

A.absolute()

B.log()

C.cosine()

D.sine()

14."现有:

list是一个合法的集合引用

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

"

答案:

C

A.for(Objecto:

list)

B.for(Objecto:

getCollection())

C.for(Objecto:

list.iterator())

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

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.以下哪些类提供了创建一个目录的方法?

答案:

A

A.File

B.DataOutput

C.Directory

D.FileDescriptor

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

publicclassExample{

publicstaticvoidmain(String[]args){

Filef=newFile(""c:

\\large.txt"");

}

}"

答案:

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

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

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

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

22."现有如下代码:

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

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

答案:

B

A.ArrayListmyList=newObject()

B.ListmyList=newArrayList()

C.ArrayListmyList=newList()

D.ListmyList=newList()

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

classExample{

publicstaticvoidmain(String[]args)throwsIOException{

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

try{

}catch(java.io.IOExceptione){

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

}

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

}

}"

答案:

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

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

C."输出BeforeTry

AttheEnd"

D."输出InsideCatch

AttheEnd"

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

答案:

A.getConstructors()

B.getPrivateMethods()

C.getDeclaredFields()

D.getImports()

 

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

答案:

AC

A.Throwable

B.Error

C.Exception

D.String

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

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.

"

B.代码不能编译通过,因为最后一条语句位于return后,不可到达

C.代码编译通过,但运行时输出异常信息

D."I'mnomal

I'mfinally."

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

classExample{

publicstaticvoidmain(String[]args)throwsIOException{

try{

return;

}finally{

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

}

}

}"

答案:

B

A.无内容输出

B.输出Finally

C.代码编译失败

D.输出异常信息

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

答案:

C

A.raiseServiceException

B.thrownewServiceException()

C.throwServiceException

D.throwsServiceException

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

答案:

D

A.throw

B.catch

C.finally

D.throws

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

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.编译失败

32."现有如下代码:

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

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

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.编译失败

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

答案:

B

A.squareRoot()

B.sqrt()

C.root()

D.sqr()

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

classExample{

publicstaticvoidmain(String[]args)throwsIOException{

if(args[0]==""hello""){

thrownewIOException();

}

}

}"

答案:

A

A.代码编译成功

B.代码编译失败,因为main()方法是入口方法,不能抛出异常

C.代码编译失败,因为IOException异常是系统异常,不能由应用程序抛出

D.代码编译失败,因为字符串应该用equals方法判定一致性

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

答案:

A.char

B.int

C.long

D.double

37."给出以下代码:

classExample{

publicstaticvoidmain(String[]args)throwsIOException{

try{

methodA();

}catch(IOExceptione){

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

}catch(Exceptione){

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

}

}

}

如果methodA()方法抛出一个IOException异常,则该程序的运行结果是什么?

"

答案:

A.无内容输出

B.代码编译失败

C.输出caughtIOException

D.输出caughtException

38."给出以下代码,执行结果是?

classExample{

publicstaticvoidmain(String[]args)throwsIOException{

aMethod();

}

staticvoidaMethod(){

try{

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

return;

}catch(Exceptione){

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

}finally{

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

}

}

}"

答案:

A.代码编译成功,但运行期间抛出异常

B.代码便以失败,因为return语句错误

C.输出Try和Finally

D.输出Try

39."以下代码中,如果test()方法抛出一个NullPointException异常时,打印输出什么内容?

classExample{

publicstaticvoidmain(String[]args)throwsIOException{

try{

test();

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

}catch(ArrayIndexOutOfBoundsExceptione){

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

}finally{

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

}

}

}"

答案:

A.打印输出Message1

B.打印输出Message2

C.打印输出Message3

D.以上都不对

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

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

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

publicabstractclassExampleextendsBase{

publicabstractvoidmethod();

}

classBase{

publicBase()throwsIOException{

thrownewIOExcept

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

当前位置:首页 > 自然科学 > 物理

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

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