锁定老帖子 主题:遇到这3道笔试题,大家有把握能做对几道
精华帖 (16) :: 良好帖 (2) :: 新手帖 (0) :: 隐藏帖 (8)
|
|
---|---|
作者 | 正文 |
发表时间:2011-07-18
第二题的答案到底是什么啊?
在我的机器上结果是这样的: try . .省略几百个 . try tryfinally try try try try try try MISSING EXCEPTION HANDLER for pc 102990820 and handler bci -1 Exception: java.lang.StackOverflowError - klass: 'java/lang/StackOverflowError' Compiled exception table : ExceptionHandlerTable (size = 1464 bytes) catch_pco = 240 (1 entries) bci -1 at scope depth 0 -> pco 11521 catch_pco = 268 (1 entries) bci -1 at scope depth 0 -> pco 11529 catch_pco = 296 (1 entries) bci -1 at scope depth 0 -> pco 11537 catch_pco = 336 (1 entries) bci -1 at scope depth 0 -> pco 11545 catch_pco = 496 (1 entries) bci -1 at scope depth 0 -> pco 8703 catch_pco = 524 (1 entries) bci -1 at scope depth 0 -> pco 8711 catch_pco = 552 (1 entries) bci -1 at scope depth 0 -> pco 8719 catch_pco = 740 (1 entries) bci -1 at scope depth 0 -> pco 8668 catch_pco = 1076 (1 entries) bci -1 at scope depth 0 -> pco 11797 catch_pco = 1104 (1 entries) bci -1 at scope depth 0 -> pco 11805 catch_pco = 1132 (1 entries) bci -1 at scope depth 0 -> pco 11813 catch_pco = 1172 (1 entries) bci -1 at scope depth 0 -> pco 11821 catch_pco = 1332 (1 entries) bci -1 at scope depth 0 -> pco 9199 catch_pco = 1360 (1 entries) bci -1 at scope depth 0 -> pco 9207 catch_pco = 1388 (1 entries) bci -1 at scope depth 0 -> pco 9215 catch_pco = 1576 (1 entries) bci -1 at scope depth 0 -> pco 9164 catch_pco = 1912 (1 entries) bci -1 at scope depth 0 -> pco 12073 catch_pco = 1940 (1 entries) bci -1 at scope depth 0 -> pco 12081 catch_pco = 1968 (1 entries) bci -1 at scope depth 0 -> pco 12089 catch_pco = 2008 (1 entries) bci -1 at scope depth 0 -> pco 12097 catch_pco = 2168 (1 entries) bci -1 at scope depth 0 -> pco 9694 catch_pco = 2196 (1 entries) bci -1 at scope depth 0 -> pco 9702 catch_pco = 2224 (1 entries) bci -1 at scope depth 0 -> pco 9710 catch_pco = 2408 (1 entries) bci -1 at scope depth 0 -> pco 9660 catch_pco = 2520 (1 entries) bci -1 at scope depth 0 -> pco 8640 catch_pco = 2568 (1 entries) bci -1 at scope depth 0 -> pco 12694 catch_pco = 2576 (1 entries) bci -1 at scope depth 0 -> pco 12699 catch_pco = 2624 (1 entries) bci -1 at scope depth 0 -> pco 12473 catch_pco = 2632 (1 entries) bci -1 at scope depth 0 -> pco 12478 catch_pco = 2680 (1 entries) bci -1 at scope depth 0 -> pco 12577 catch_pco = 2688 (1 entries) bci -1 at scope depth 0 -> pco 12582 catch_pco = 8364 (1 entries) bci -1 at scope depth 0 -> pco 11513 catch_pco = 8472 (1 entries) bci -1 at scope depth 0 -> pco 11789 catch_pco = 8580 (1 entries) bci -1 at scope depth 0 -> pco 12065 catch_pco = 8668 (2 entries) bci 40 at scope depth 0 -> pco 12650 bci 14 at scope depth 0 -> pco 11493 catch_pco = 8760 (3 entries) bci 66 at scope depth 0 -> pco 11321 bci -1 at scope depth 0 -> pco 10526 bci 56 at scope depth 0 -> pco 11346 catch_pco = 9256 (3 entries) bci 66 at scope depth 0 -> pco 11369 bci -1 at scope depth 0 -> pco 10806 bci 56 at scope depth 0 -> pco 11394 catch_pco = 9752 (3 entries) bci 66 at scope depth 0 -> pco 11413 bci -1 at scope depth 0 -> pco 11086 bci 56 at scope depth 0 -> pco 11434 catch_pco = 10560 (2 entries) bci 40 at scope depth 0 -> pco 12515 bci 14 at scope depth 0 -> pco 12341 catch_pco = 10840 (2 entries) bci 40 at scope depth 0 -> pco 12411 bci 14 at scope depth 0 -> pco 12361 catch_pco = 11120 (2 entries) bci 40 at scope depth 0 -> pco 12623 bci 14 at scope depth 0 -> pco 12381 catch_pco = 11584 (3 entries) bci 76 at scope depth 0 -> pco 10477 bci -1 at scope depth 0 -> pco 10521 bci 66 at scope depth 0 -> pco 10497 catch_pco = 11860 (3 entries) bci 76 at scope depth 0 -> pco 10761 bci -1 at scope depth 0 -> pco 10801 bci 66 at scope depth 0 -> pco 10782 catch_pco = 12136 (3 entries) bci 76 at scope depth 0 -> pco 11041 bci -1 at scope depth 0 -> pco 11081 bci 66 at scope depth 0 -> pco 11062 catch_pco = 12460 (1 entries) bci -1 at scope depth 0 -> pco 12406 catch_pco = 12468 (1 entries) bci -1 at scope depth 0 -> pco 12401 catch_pco = 12488 (2 entries) bci 40 at scope depth 0 -> pco 12520 bci 14 at scope depth 0 -> pco 11473 catch_pco = 12564 (1 entries) bci -1 at scope depth 0 -> pco 12510 catch_pco = 12572 (1 entries) bci -1 at scope depth 0 -> pco 12505 catch_pco = 12680 (1 entries) bci -1 at scope depth 0 -> pco 12618 catch_pco = 12688 (1 entries) bci -1 at scope depth 0 -> pco 12613 catch_pco = 12708 (2 entries) bci 40 at scope depth 0 -> pco 12416 bci 14 at scope depth 0 -> pco 11453 Could not load hsdis-.jnilib; library not loadable; PrintAssembly is disabled # guarantee(false) failed: missing exception handler |
|
返回顶楼 | |
发表时间:2011-07-18
第二题c finally在任何情况下都是执行的
|
|
返回顶楼 | |
发表时间:2011-07-18
最后修改:2011-07-18
gu__sofia 写道
第二题c finally在任何情况下都是执行的
try{ System.out.println("try"); System.exit(0); }finally{ System.out.println("finally"); } 或者JVM崩溃了
|
|
返回顶楼 | |
发表时间:2011-07-18
第二题,只留下面2句代码,
System.out.println("try"); foo(); 测试后发现,在N次try以后,报异常,异常类型为StackOverflowError 所以,第二题catch里异常类型不符,所以只打印try和finally,选C呢~~ |
|
返回顶楼 | |
发表时间:2011-07-18
20067765 写道 第二题,只留下面2句代码,
System.out.println("try"); foo(); 测试后发现,在N次try以后,报异常,异常类型为StackOverflowError 所以,第二题catch里异常类型不符,所以只打印try和finally,选C呢~~ Error也是Throwable的啊。按照道理,当栈溢出后,就要打出catch和finally了。我测试的结果看不到catch,奇怪了。另外, 我的是tryfinallyfinally这种形式,不知道为什么没换行,难道是栈溢出导致的? |
|
返回顶楼 | |
发表时间:2011-07-18
第二题应该是只有try和catch才对,可是测试结果却不是。
|
|
返回顶楼 | |
发表时间:2011-07-18
最后修改:2011-07-18
我把catch去掉后,还是打tryfinally。
|
|
返回顶楼 | |
发表时间:2011-07-18
这三道题都挺诡异的
|
|
返回顶楼 | |
发表时间:2011-07-18
lz12366 写道 神之小丑 写道 第三题 可以这样:
int A; if(1!=1)//可以直接用if(false) A = 1; System.out.println(A); 在eclipse下 第一句正常 第二个报 The local variable A may not have been initialized 这样可以。。不错、。。 这样直接语法错误了 |
|
返回顶楼 | |
发表时间:2011-07-18
悲剧了 写道 第二题应该是C吧
想想应该是c 运行发现一直try try finally 调试都进入的是try |
|
返回顶楼 | |