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

上传人:b****8 文档编号:10281579 上传时间:2023-02-09 格式:DOCX 页数:77 大小:35.42KB
下载 相关 举报
精选新版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

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

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

精选新版JAVASE综合考核题库188题含标准答案

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

一、选择题

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

publicclassExample{

publicstaticvoidmain(String[]args){

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

}

}"

答案:

A

A.输出NaN

B.打印输出Infinity

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

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

2."关于以下代码正确的说法是:

1.publicclassExample{

2.intx=0;

3.

4.publicExample(intinVal)throwsException{

5.if(inVal!

=this.x){

6.thrownewException(""Invalidinput"");

7.}

8.}

9.

10.publicstaticvoidmain(String[]args){

11.Examplet=newExample(4);

12.}

13.}"

答案:

A.代码在第1行编译错误

B.代码在第4行编译错误

C.代码在第6行编译错误

D.代码在第11行编译错误

3."现有如下代码:

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

4.下列关于Math类说法错误的是

答案:

A.java.lang.Math类是final类,因此不能被其他类继承

B.java.lang.Math类的构造器是私有的,即声明为private,不能实例化一个Math类的对象

C.java.lang.Math类上定义的所有常量和方法均是public和static的,因此可以直接通过类名调用

D.min()和max()方法的参数之一,如果是NaN值,则方法将返回另一个参数值

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

答案:

A.absolute()

B.log()

C.cosine()

D.sine()

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

答案:

A.char

B.int

C.long

D.double

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

答案:

B

A.squareRoot()

B.sqrt()

C.root()

D.sqr()

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

答案:

D

A.-0.12和0.56E3

B.0.12和1.1E1

C.-23.45和0.0

D.0.356和0.03

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

publicclassExample{

publicstaticvoidmain(String[]args){

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

}

}"

答案:

B

A.输出Integer.MAX_VALUE

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

C.编译失败

D.运行时输出异常信息

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

publicclassExample{

publicstaticvoidmain(String[]args){

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

}

}"

答案:

C

A.代码编译失败

B.输出0.0

C.输出-0.0

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

11."现有如下类型:

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

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

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

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

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

答案:

A

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

B.代码容易编写

C.类型安全

D.运行速度快

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

答案:

BD

A.Dictionary

B.List

C.Map

D.Set

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

答案:

B

A.Collection

B.List

C.Map

D.Set

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

答案:

C

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

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

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

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

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

答案:

B

A.ArrayListmyList=newObject()

B.ListmyList=newArrayList()

C.ArrayListmyList=newList()

D.ListmyList=newList()

19."现有:

list是一个合法的集合引用

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

"

答案:

C

A.for(Objecto:

list)

B.for(Objecto:

getCollection())

C.for(Objecto:

list.iterator())

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

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

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

21."现有:

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

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

答案:

A."publicinterfaceColor{

}

publicclassShape{

privateColorcolor;

}"

B."publicinterfaceComponent{

}

publicclassCpmtaomerimplementsComponent{

privateComponent[]children;

}"

C."publicclassSpecies{

}

publicclassAnimal{

privateSpeciesspecies;

}"

D."publicclassAnimal{

publicinterfaceSpecies{

}

privateSpeciesspecies;

}"

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

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

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

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

答案:

A.getConstructors()

B.getPrivateMethods()

C.getDeclaredFields()

D.getImports()

 

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

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

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

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

28."现有如下代码:

publicclassExampleextendsUtils{

publicstaticvoidmain(String[]args){

try{

System.out.println(newExample().getInt(""42""));

}catch(NumberFormatExceptione){

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

}

}

intgetInt(Stringarg)throwsNumberFormatException{

returnInteger.parseInt(arg);

}

}

classUtils{

intgetInt(Stringarg){

return42;

}

}

该代码执行的结果是?

"

答案:

B

A.NFExc

B.42

C.42NFExc

D.编译失败

29.关于异常处理,说法错误的是?

答案:

C

A.try…catch…finally结构中,必须有try语句块,catch语句块和finally语句块不是必须的,但至少要两者取其一

B.在异常处理中,若try中的代码可能产生多种异常则可以对应多个catch语句,若catch中的参数类型有父类子类关系,此时应该将子类放在后面,父类放在前面

C.一个方法可以抛出多个异常,方法的返回值也能够是异常

D.Throwable是所有异常的超类

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."现有如下代码:

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

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

publicabstractclassExampleextendsBase{

publicabstractvoidmethod();

}

classBase{

publicBase()throwsIOException{

thrownewIOException();

}

}"

答案:

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

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

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

D.代码编译成功

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

答案:

CD

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

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

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

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

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

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

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

答案:

C

A.raiseServiceException

B.thrownewServiceException()

C.throwServiceException

D.throwsServiceException

38."现有代码如下:

publicclassExample{

voidtopGo(){

try{

middleGo();

}catch(Exceptione){

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

}

}

voidmiddleGo()throwsException{

go();

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

}

voidgo()throwsException{

thrownewException();

}

publicstaticvoidmain(String[]args){

Exampleexample=newExample();

example.topGo();

}

}

该代码的执行结果是?

"

答案:

B

A.输出latemiddle

B.输出catch

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

当前位置:首页 > 解决方案 > 学习计划

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1