a我考网

 找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 81|回复: 0

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

[复制链接]
发表于 2012-8-4 12:33:16 | 显示全部楼层 |阅读模式
  Q76.Read the following snippet carefully: d( t3 A' h  I$ ^
  1. public synchronized void someMethod() {
' b$ r& C, U) E. }8 H( ~  2. //lots of code8 {9 r- c0 c1 T+ l% n  i+ w( I4 X
  3. try {8 d; k1 I  O) i! P( W2 Z3 \+ t
  4. Thread.sleep(500);0 ^! R9 f6 ^% S0 ]# `4 H
  5. } catch(InterruptedException e) {
0 P7 G* U* _9 p) t' s1 f  6. //do some things here.) R% Y# j9 s4 M& U* J+ l) f/ L
  7. }
, ^# U, y: p, F& b  8. //more and more code here
4 ~% @! e3 p, |1 B9 r% P+ N  9. }* Y; E: a" o! M* I
  Select all correct answers. {1 b9 c0 o4 m
  a. The code causes compilation error - sleep cannot be called inside synchronized methods.2 C6 K, s2 v' G* n
  b. The Thread sleeps for at least 500 milliseconds in this method if not interrupted.
2 R$ P- N  ]% s  _' v3 M, e' ?. n- p( Y$ V  c. When the thread “goes to sleep” it releases the lock on the object.8 \( ^+ U6 n  D  V
  d. The “sleeping” Threads always have the lock on the Object.* A4 L5 ?( V# p' y/ I4 C
  Q77.What will be the result of attempt to compile and the run the following code, d+ B) V" H9 b: g- k/ b. S2 u0 t
  1. public class ADirtyOne {5 F$ \8 M% J/ r
  2. public static void main(String args[]) {
) E6 l' G, \/ U. N  3. System.out.println(Math.abs(Integer.MIN_VALUE));: Q* K% V: |* h0 D9 u
  4. }1 d* L8 i3 H( `$ ?
  5. }
/ q1 K. n6 g; z$ x7 w& B; w1 B  Select one correct answer6 }8 @6 H# d( [( w
  a. Causes a compilation error.
1 R4 ~/ O- H" S( {6 `2 d  b. Causes no error and the value printed on the screen is less than zero.9 Z+ h: w4 ^2 l3 X) X/ @( D, J
  c. Causes no error and the value printed on the screen is one more than Integer.MAX_VALUE1 [# |# K  H! U3 |; j
  d. Will throw a runtime exception due to overflow - Integer.MAX_VALUE is less in magnitue than Integer.MIN_VALUE.6 z  q$ o" i) y
  Q78.What is the result of attempting to compile and run the following program) G) i0 V2 Q7 S, _; a3 T3 v* P  @6 r
  1. public class Test {
2 h+ g9 X' _! ~+ a+ C( `. s  2. public void method(Object o) {" i3 d- x- A0 R# R( N- o
  3. System.out.println(“Object Version”);
2 A* e* M; r1 i( Z+ f/ M0 L  4. }3 F4 O7 L! g# A, p
  5. public void method(String s) {
" @: G  n2 [; c1 E. L  6. System.out.println(“String Version”);
8 w7 Q' l: x  b1 R8 h  7. }# u0 e7 n& _# I* J. G
  8. public static void main(String args[]) {
$ E: o, E$ q. Y2 u5 U' \  9. Test test = new Test();
3 N! R5 [, `5 [& z' ]$ p' O  10. test.method(null);( H. l6 s( U6 R  |1 J- S, Q9 ], ?
  11. }( H! G1 ~2 m2 I
  12. }% {9 D$ I3 z( `" y
  Select one correct answer
9 y& V- ^- f' Y9 R5 N  a. The code does not compile.3 Z* _8 F& H6 f( p& G6 Q
  b. The code compiles cleanly and shows “Object Version”./ s' S; _( @7 j, m" H: T# D$ _0 T
  c. The code compiles cleanly and shows “String Version”.
* G: c5 R5 _3 U! Y4 u9 W, n5 m8 y  d. The code throws an Exception at Runtime.
" E3 u! B2 D" `/ W  76. bd. u" E1 \7 y* s
  77. b
5 o$ b( l/ u' m: E, I# w4 `  78. c
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-5-22 00:40 , Processed in 0.319267 second(s), 21 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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