a我考网

 找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 62|回复: 0

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

[复制链接]
发表于 2012-8-4 12:33:16 | 显示全部楼层 |阅读模式
  Q79.What is the result of attempting to compile the following program/ M' D$ l' o, o, x* O1 |0 O
  1. public class Test {- \% H8 a% H! ^/ v/ o8 W
  2. public void method(StringBuffer sb) {4 I1 R7 z9 }5 l4 P
  3. System.out.println(“StringBuffer Verion”);6 X- _* n! O& G4 U! c
  4. }; o4 F  a/ l1 {: o5 I2 G4 }* d* L( C" [
  5. public void method(String s) {2 [7 P5 `. `  ^' P* q  U; E' N, N
  6. System.out.println(“String Version”);) O( ?; a$ B5 o+ B6 s, ~
  7. }
  g; e$ K' w/ W  e( g  8. public static void main(String args[]) {  \5 m: {# s/ D6 ~- V/ G
  9. Test test = new Test();9 H! G" C. a: i4 E% a
  10. test.method(null);- U7 y, C1 Y) u0 O1 ^/ Q3 u
  11. }, [# D$ i* \( u8 z, S9 l
  12. }
2 Z' [  n) o. f- Z  Select one correct answer3 y  B4 _$ R0 w- g6 t: i
  a. The code does not compile.
& F4 P$ G2 Z; ?- M# ~/ J( @7 V  b. The code compiles correctly and shows
) i  }7 U; Z( L( H5 V' S& T  c. The code compiles correctly and shows “String Version”.' `) c* f/ ^& Y. q% f
  d. The code throws an Exception at Runtime. NullPointerException in the 2nd line of the main method.
9 r  T4 n/ {" C/ L0 n  Q80.What is the requirement of the class which implements the following Interface; V4 P" \6 f) n/ [: e
  1. public interface Test {
; ?6 j3 f. ]# P  2. void someMethod();5 L% C2 _; m( J7 r( L. D8 j, T/ L+ k
  3. }
" ?; X1 U2 X7 t, l8 g  Select all correct answers+ A& O; a+ e1 ^( K# ^" K4 ?
  a. Should have someMethod which must be necessarily declared as public.3 L" f6 G, a+ a9 C+ [
  b. Should have someMethod which could be “friendly” or public
) L/ G- v8 o3 b6 ?# I% @! `( Y) q% R  c. Should have someMethod which should not throw any checked exceptions.
: d9 ?$ v! h; U) [! h' I6 y3 n8 o  d. Should have someMethod which cannot be sychronized as sychronized is not in the signature of the interface definition.
6 m3 Y; p* W2 ^4 d' B, C  Q81.What is the result of attempting to compile and run the following program?
9 b) ]+ ?9 M3 t. i, r  1. public class AStringQuestion {
" h4 p1 }- D. w. y: D: k  2. static String s1;
9 _" z& D' t) \, O8 G' p  3. static String s2;
; K1 a* S  j! k3 o  4. public static void main(String args[]) {9 H7 q- j# F) @: v5 y
  5. s2 = s1+s2;
' D/ u/ b) R1 v# h8 N/ e- |  e, e  6. System.out.println(s2);
& O, W1 |' A- U, Z- _  7. }
" R# K( h) @! S2 U& \* ~  8. }6 @8 X( M0 L- y$ Q5 L( j
  [Select one correct answer]
% A" c% g  n8 O; q" w9 d, G/ n  a. Will cause a compilation error. “StringBuffer Version”.7 l) p( F* Z- M6 B, }: m" @1 q- @$ r
  b. Runtime Execption -
" Q- L, V4 g$ M) C  c. Will compile successfully and print “nullnull” on the screen.4 C/ i3 {6 [4 K! Q' a
  d. Will compile successfully and print an empty line on the screen.
# m7 Y/ M; N& H+ x& @  79. a
1 H2 t2 O6 D% _( d1 k: n* Y. s' _) `  80. ac  E/ C- J+ U4 y, X0 ?0 c% z
  81. c
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-5-21 23:22 , Processed in 0.194707 second(s), 21 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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