a我考网

 找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 82|回复: 0

[考试试题] 2011年JAVA认证模拟题第二阶段(26)

[复制链接]
发表于 2012-8-4 12:33:16 | 显示全部楼层 |阅读模式
  Q76.Read the following snippet carefully
0 a! f- ]# N2 [4 l' _  1. public synchronized void someMethod() {( }+ x' X5 Z! k& M* ^
  2. //lots of code! r9 H: V& |( a
  3. try {3 J" a4 \+ C" d6 @  f3 ^
  4. Thread.sleep(500);/ s' O1 _; r$ c6 j( a2 s/ b5 R
  5. } catch(InterruptedException e) {
- U1 @2 K$ x$ q1 _" c# y  6. //do some things here., w! f3 |  W: Z* I( |/ F5 F1 g. i
  7. }5 u5 @% |- Z7 V* e) X
  8. //more and more code here
/ P1 b1 \% N0 _; H3 v5 k" {  9. }
$ J  _* R5 G: h, \- A6 Z, G" Z  Select all correct answers5 G5 l% C" N7 ^; ?1 P7 V5 r
  a. The code causes compilation error - sleep cannot be called inside synchronized methods.  ^8 ^9 `" q; |6 g
  b. The Thread sleeps for at least 500 milliseconds in this method if not interrupted.
% y% C& G5 F& N  c. When the thread “goes to sleep” it releases the lock on the object.
& p9 B2 v: p  v7 ^  d. The “sleeping” Threads always have the lock on the Object.% u1 u3 Y1 b6 w9 s
  Q77.What will be the result of attempt to compile and the run the following code+ F/ O& r. i5 x# F
  1. public class ADirtyOne {0 V) l7 |# m, e! h& R+ Y
  2. public static void main(String args[]) {! W. U! R; n/ u/ `2 W( l5 K$ N+ N- {( L
  3. System.out.println(Math.abs(Integer.MIN_VALUE));
4 ~( ]0 v. O5 E+ U  4. }
' i1 X# R. v. c& ^  5. }7 u, z& p: a- |0 N$ B) {
  Select one correct answer' z% d5 ^. T+ V$ E, v' e; g0 Y
  a. Causes a compilation error.: o6 t# A3 s! M
  b. Causes no error and the value printed on the screen is less than zero.# v- G+ Y+ f8 F, p
  c. Causes no error and the value printed on the screen is one more than Integer.MAX_VALUE; A  i1 B( j7 }8 w. T  v
  d. Will throw a runtime exception due to overflow - Integer.MAX_VALUE is less in magnitue than Integer.MIN_VALUE., I- u7 ?5 a& m0 @  S- K3 @
  Q78.What is the result of attempting to compile and run the following program7 V& h5 B6 W) d" }8 l6 I
  1. public class Test {
& F: `, B6 e/ o/ l) `9 s8 d  2. public void method(Object o) {8 {# J* e9 T- z( N
  3. System.out.println(“Object Version”);2 \" z$ r8 G! s9 c% t  A7 r7 {* o
  4. }' ?/ }# b0 O5 b/ g7 U
  5. public void method(String s) {
- A* e5 P6 J) f) w& a  6. System.out.println(“String Version”);8 N6 {2 F* a0 S
  7. }: Q3 U. o) C3 d* C
  8. public static void main(String args[]) {
$ P4 c4 M, ~" a, t- c- y! Z  9. Test test = new Test();: c3 v! Z8 J6 i  P# c$ _) n5 J' Z
  10. test.method(null);
2 ]$ X$ y9 d+ n1 M  11. }
+ b! o- H7 `1 Y, N' G( V" ?& a  12. }
9 J6 \9 t9 T2 O: e, J! \9 V0 ^  Select one correct answer9 d5 I# {  N8 w4 z  w, u8 A
  a. The code does not compile.& }4 S9 B7 D" {# o9 _& c
  b. The code compiles cleanly and shows “Object Version”.
7 M8 K+ a% D" W( @  c. The code compiles cleanly and shows “String Version”.
. T, j* ]- ~" b4 u  d. The code throws an Exception at Runtime.
& N3 d1 H7 R9 ]0 v! L  76. bd
) @, t: ]' L1 m# [  77. b  m  o, L1 N0 A( n0 Y+ M! ]4 N6 s% ?
  78. c
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|Woexam.Com ( 湘ICP备18023104号 )

GMT+8, 2024-6-3 05:17 , Processed in 0.227464 second(s), 21 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表