精编JAVASE综合考核题库完整版188题含答案.docx

上传人:b****8 文档编号:9772083 上传时间:2023-05-21 格式:DOCX 页数:77 大小:34.38KB
下载 相关 举报
精编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.以下哪些语句用于创建一个Map实例?

答案:

D

A.Mapm=newMap();

B.Mapm=newMap(initcapacity,incrementcapacity);

C.Mapm=newMap(newCollection());

D.以上都不对

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

publicclassExample{

publicstaticvoidmain(String[]args){

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

}

}"

答案:

C

A.代码编译失败

B.输出0.0

C.输出-0.0

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

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

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

4."给出以下代码,为了结果输出-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()

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.以下哪些集合接口支持重复元素存在?

答案:

B

A.Collection

B.List

C.Map

D.Set

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

答案:

D

A.Set

B.List

C.Collection

D.Map

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

答案:

C

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

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

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

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

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

答案:

B

A.ArrayListmyList=newObject()

B.ListmyList=newArrayList()

C.ArrayListmyList=newList()

D.ListmyList=newList()

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

答案:

A.InputStream和OutputStream类是基于字节流的

B.ObjectInputStream类和ObjectOutputStream类不支持序列化的对象

C.Reader和Writer是基于字符流的

D.Reader类和Writer类是支持对象序列化的首选

12."现有:

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

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

答案:

A.absolute()

B.log()

C.cosine()

D.sine()

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

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

15."现有如下类型:

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

16."现有:

publicclassExample{

publicstaticvoidmain(String[]args){

//插入代码处

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

}

}

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

"

答案:

A.Mapc=newSortedMap();

B.HashMapc=newHashMap();

C.SortedMapc=newTreeMap();

D.Mapc=newLinkedHashMap();

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

答案:

A

A.File

B.DataOutput

C.Directory

D.FileDescriptor

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

publicclassExample{

publicstaticvoidmain(String[]args){

Filef=newFile(""c:

\\large.txt"");

}

}"

答案:

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

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

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

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

19."现有:

f是一个File类实例的合法引用

fr是一个FileReader类实例的合法引用

br是一个BufferedReader类实例的合法引用

如下代码:

Stringline=null;

//插入代码处

System.out.println(line);

哪一行代码插入到插入代码处将循环一次输出文本文件的一行?

"

答案:

A.while((line=f.read())!

=null){

B.while((line=fr.read())!

=null){

C.while((line=br.read())!

=null){

D.while((line=br.readLine())!

=null){

20."现有:

Strings=""writealinetoafile"";

w.print(s+""\n"");

哪一个是对的?

"

答案:

A.w既可以是PrintWriter类型,也可以是BufferedWriter类型

B.w既不可以是PrintWriter类型,也不可以是BufferedWriter类型

C.w可以是PrintWriter类型,但不可以是BufferedWriter类型

D.w既可以是BufferedWriter类型,也可以是PrintWriter类型

21.以下哪些是FileOutputSteram类的正确构造形式?

答案:

A.FileOutputStream(FileDescriptorfd)

B.FileOutputStream(Stringn,booleana)

C.FileOutputStream(booleana)

D.FileOutputStream(Filef)

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

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

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

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]

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

classExample{

publicstaticvoidmain(String[]args)throwsIOException{

try{

return;

}finally{

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

}

}

}"

答案:

B

A.无内容输出

B.输出Finally

C.代码编译失败

D.输出异常信息

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

答案:

A.getConstructors()

B.getPrivateMethods()

C.getDeclaredFields()

D.getImports()

 

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

答案:

A

A.IOException

B.NullPointerException

C.OutOfMemoryError

D.

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

答案:

A."publicinterfaceColor{

}

publicclassShape{

privateColorcolor;

}"

B."publicinterfaceComponent{

}

publicclassCpmtaomerimplementsComponent{

privateComponent[]children;

}"

C."publicclassSpecies{

}

publicclassAnimal{

privateSpeciesspecies;

}"

D."publicclassAnimal{

publicinterfaceSpecies{

}

privateSpeciesspecies;

}"

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

答案:

C

A.运行时异常和异常

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

C.错误和异常

D.错误和运行时异常

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

代码片段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抛出异常

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

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"

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

答案:

AC

A.可以有多个catch

B.只能有一个catch

C.可以没有catch

D.finally必须有

32."当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

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

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

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

publicclassExample{

publicstaticvoidmain(String[]args){

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

}

}"

答案:

B

A.输出Integer.MAX_VALUE

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

C.编译失败

D.运行时输出异常信息

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

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."

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

答案:

A.char

B.int

C.long

D.double

37."现有如下代码:

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

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

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

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

classExample{

publicstaticvoidmain(String[]args)throwsIOException{

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

try{

}catch(java.io.IOExceptione){

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

}

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

}

}"

答案:

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

B.代码编译失败,因为未导入IOExcepti

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

当前位置:首页 > 初中教育 > 语文

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

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