最新精选2020年JAVASE综合测试题库188题(含标准答案) 下载本文

内容发布更新时间 : 2024/10/21 20:26:44星期一 下面是文章的全部内容请认真阅读。

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

一、选择题

1.\以下代码的输出结果是什么?

public class Example {

public static void main(String[] args) {

System.out.println(Math.round(Float.MAX_VALUE)); } }\答案:B

A.输出Integer.MAX_VALUE

B.输出一个最接近Float.MAX_VALUE的整数 C.编译失败

D.运行时输出异常信息

2.\现有代码如下:

public class Example {

void topGo() { try {

middleGo();

} catch (Exception e) {

System.out.println(\ } }

void middleGo() throws Exception { go();

System.out.println(\ }

void go() throws Exception { throw new Exception(); }

public static void main(String[] args) { Example example = new Example(); example.topGo(); } }

该代码的执行结果是?\答案:B

A.输出late middle B.输出catch

C.输出late middle catch D.输出catch late middle

3.\如下代码执行后的输出结果是? public class Example {

public static void main(String[] args) { try {

throw new Exception(); } catch (Exception e) { try {

throw new Exception(); } catch (Exception e2) {

System.out.println(\ }

System.out.println(\ }

System.out.println(\ } }\答案:D

A.inner outer B.middle outer

C.inner middle outer D.编译失败

4.\现有如下代码:

public class Example {

public static void main(String[] args) {// a new Example().topGo(); }

void topGo() {// b middleGo(); }

void middleGo() {// c go();

System.out.println(\ }

void go() {// d

throw new Exception(); } }

为了使代码能够编译通过,需要在哪个地方加入声明throws Exception?\答案:B A.d B.c和d C.b、c和d D.a、b、c和d

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

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

C.如果有finally语句,return语句将在finally语句执行完毕后才会返回 D.只有当异常抛出时,finally语句才获得执行

6.\关于以下代码,说法正确的是?

class Example{

public static void main(String[] args) throws IOException { if (args[0] == \ throw new IOException(); } } }\答案:A A.代码编译成功

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

C.代码编译失败,因为IOException异常是系统异常,不能由应用程序抛出 D.代码编译失败,因为字符串应该用equals方法判定一致性

7.\关于以下代码,说法正确的是?

class Example {

public static void main(String[] args) throws IOException { System.out.println(\ try {

} catch (java.io.IOException e) {

System.out.println(\ }