最新精编JAVASE综合考核题库完整版188题(含标准答案)

最新精编JAVASE综合考核题库完整版188题(含标准答案)


2024年3月11日发(作者:)

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

一、选择题

1."给出以下代码,为了结果输出-12.0,方法method(d)应为以下哪个方法?

public class Example {

public static void main(String[] args) {

double d = -11.1;

double d1 = method(d);

n(d1);

}

}"

答案: A

()

()

()

()

2."现有如下代码:

public class Example {

public static void main(String[] args) {

try {

n(""before"");

doRisyThing();

n(""after"");

} catch (Exception e) {

n(""catch"");

}

n(""done"");

}

public static void doRisyThing() throws Exception{

//this code returns unless it throws an Exception

}

}

该代码可能的执行结果有哪些?"

答案:

catch

after done

catch done

after catch

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

class Example {

private void method1() throws Exception {

throw new RuntimeException();

}

public void method2() {

try {

method1();

} catch (RuntimeException e) {

n(""Caught Runtime Exception"");

} catch (Exception e) {

n(""Caught Exception"");

}

}

public static void main(String[] args) throws IOException {

Example a = new Example();

2();

}

}"

答案:

A.代码编译失败

B.输出Caught Runtime Exception

C.输出Caught Exception

D.输出Caught Runtime Exception和Caught Exception

4."以下代码的输出结果是什么?选择所有的正确答案。

class Example {

public static void main(String[] args) throws IOException {

for (int i = 0; i < 10; i++) {

try {

try {

if (i % 3 == 0)

throw new Exception(""E0"");

n(i);break;

} catch (Exception inner) {

i *= 2;

if (i % 3 == 0)

throw new Exception(""E1"");

} finally {


发布者:admin,转转请注明出处:http://www.yc00.com/news/1710119269a1703761.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信