设为首页收藏本站联系我们

JAVA中文站

 找回密码
 注册会员

QQ登录

只需一步,快速开始

扫一扫,访问微社区

搜索
JSP虚拟主机本站QQ群:36839023广告位招租JSP空间
查看: 7093|回复: 0

SCJP考试题310-025(第一套)

[复制链接]

该用户从未签到

发表于 2009-1-4 14:18:59 | 显示全部楼层 |阅读模式
这是SCJP的考试原题,是1999-2000期间的!提供给想考SCJP的参考!
2 ]( M6 U+ S- l4 p    我这还有其他的一些,如果全部打印可能100多页(双面)的样子!我将陆续的在这里粘贴出来!(如果可以的话),一共分为几套!这第一套只有19题,其他的几套有点多,300多题的都有,我归纳的,我同事说看完了它,考试就没问题,所以我就搜集了这么多,我也看的头大,所以发出来给大伙分享,敬请关注!!
8 q5 |/ [# g$ D# }1. Which statement are characteristics of the >> and >>> operators.
6 P# m" y& `' CA. >> performs a shift
7 u) ?! y' i! u# ]& A; OB. >> performs a rotate
/ ~( e. c: ]9 {# y6 [C. >> performs a signed and >>> performs an unsigned shift, r" A) |( Q/ U8 M0 P
D. >> performs an unsigned and >>> performs a signed shift5 @1 ?+ u0 E' Z+ y
E. >> should be used on integrals and >>> should be used on floating8 n" }- Y) [3 w
point types8 n: p8 \$ J" I& D
C.0 _) c) p4 f6 {: N/ T+ e1 `
2. Given the following declaration- B- B0 P6 V7 V' L, C
String s = "Example";: g$ G/ u- F1 E! M1 y+ |' Q/ p
Which are legal code?9 S5 p1 q# }$ J, U' Z
A. s >>> = 3;
; i: Q# k& V& Y5 H7 k3 ]B. s[3] = "x";
/ ^. N' V4 t4 V1 l; ^: XC. int i = s.length();
( [! F. W8 b2 Q% ?D. String t = "For " + s;
8 I5 G9 C$ @: L% bE. s = s + 10;
# @  U8 ?0 c6 m' yCDE.
1 l) |* t. I5 y  H0 U/ n% t) k3. Given the following declaration
; o4 c( |2 U7 J$ ~String s = "hello";
2 ]7 R6 w% e0 }" D/ PWhich are legal code?9 ^9 ?4 d/ h& w: }5 S/ D# ?) K' h$ `
A. s >> = 2;- W* N6 i, p$ r" b( ~% S9 Y) B
B. char c = s[3];
7 l/ g2 @+ g# u' ZC. s += "there";6 Z$ G+ r  P' m6 A- d/ ]
D. int i = s.length();
9 a6 w% @% y7 KE. s = s + 3;
' K0 [$ M' I* FCDE.
' G; ?! }4 e0 [2 L' |4. Which statements are true about listeners?
' b: e" _0 R+ u" [5 fA. The return value from a listener is of boolean type.
4 t7 o9 Q& l- `B. Most components allow multiple listeners to be added.
7 E* n+ a* p& B& O0 V* bC. A copy of the original event is passed into a listener method.) B2 d$ t$ \  m
D. If multiple listeners are added to a single component, they all must6 B1 D% ~1 i+ _1 d! g
all be friends to each other.
6 i6 a' E! x9 |- }* FE. If the multiple listeners are added to a single component, the order" j% I2 R: G% |0 |7 u
[in which listeners are called is guaranteed].4 @2 f7 Y4 L# j  n4 I4 ?- U
BC.7 ?" z( q; k0 ?: |8 X, i4 Q7 o5 h
5. What might cause the current thread to stop executing." g, z: R" C: ]% y5 |" T
A. An InterruptedException is thrown.. [6 g5 z0 s# T0 C" A3 L
B. The thread executes a wait() call.
% M5 m3 q1 ?" z$ D5 h8 ]C. The thread constructs a new Thread.
3 P, x# z' _0 H$ x" N3 t5 SD. A thread of higher priority becomes ready.. b& O9 m0 ]# z7 q7 P6 A7 Z, P
E. The thread executes a waitforID() call on a MediaTracker.
- z+ I5 \# G9 |. MABDE.7 T8 i) m' s( T+ d, _( ^! Q
6. Given the following incomplete method.( w  V; z* }( a% I7 E+ w: Q& T5 H
1. public void method(){
2 G. i( _5 r8 k/ A& J2 g* X2.1 Y3 P$ u9 ~" _4 b
3. if (someTestFails()){
+ ]: s" T; O1 @* I8 b$ a- ?0 b4.
  ?4 n! \$ e6 C5 c- w8 j5. }+ v, @6 n$ f) E: r3 z) s/ R" q2 N
6.1 r" g: s& @2 M9 J( F( z! |
7.}
5 g4 Y0 ?% j9 \# {: t$ gYou want to make this method throw an IOException if, and only if, the: [& T: D8 M, |5 V8 F7 r5 g6 N
method someTestFails() returns a value of true.
+ ]# B. O; X, Q+ k' J; xWhich changes achieve this?2 J/ d' ~) x! W. J
A. Add at line 2: IOException e;
$ U/ w. C* W1 bB. Add at line 4: throw e;
5 V/ a0 t9 L" s8 WC. Add at line 4: throw new IOException();& Z" t8 G. u  X  _. ?
D. Add at line 6: throw new IOException();! c/ J3 ^% _4 H! n* }
E. Modify the method declaration to indicate that an object of [type]
6 F; h9 b. H3 \# ~! G0 k' LException might be thrown.1 H5 ]  G$ ~; j
CE.2 a2 d2 }# Q& d0 C; v
7. Which modifier should be applied to a method for the lock of the
6 j' X7 a8 Y3 @; Dobject this to be obtained prior to executing any of the method body?$ O: V8 W; b5 L) `3 O' W: \
A. final
- P( [6 X) L5 n. s& CB. static0 Q6 t% n# {8 f$ y) v
C. abstract
' T0 @% h  }6 \D. protected! F$ \2 |9 S& c# ?
E. synchronized
& H9 X7 X1 i" _5 `7 q! oE.
+ Q" L$ v) J: x0 ]( }7 u* D8. Which are keywords in Java?1 Y+ v+ c! G% S* i
A. NULL
' p9 O: A2 M' s, ?+ GB. true
: Y2 V5 U9 b$ ^+ \& oC. sizeof/ w' z$ F8 X6 `( B( [! P
D. implements9 U7 C6 `- K" p, }8 ]) C2 O! M
E. instanceof
* U# L6 G6 S' K+ n+ fDE.1 W% S, w- ?" A) _' b- A
9. Consider the following code:
: U9 I+ S: D5 OInteger s = new Integer(9);
7 h- A0 h: V6 G" q' O) zInteger t = new Integer(9);
3 }1 m  u: h: ?0 O0 E2 B3 FLong u = new Long(9);9 b" q" A. W; B
Which test would return true?& j! l5 M2 p9 O* H3 S
A. (s==u)' _" y  |% B% u7 \8 y$ o) _* C
B. (s==t)
4 q- d' H; g; l- j, i* u4 Y) NC. (s.equals(t))
! I% R8 ^/ D+ ]5 A+ q1 q5 Q  FD. (s.equals(9))8 p- i( s% Q. K% j/ T4 Y/ G
E. (s.equals(new Integer(9))
1 `! `& N: k5 A5 f9 k4 r. G2 v- lCE.7 @0 g- n/ E3 K/ j* W/ j; A+ b
10. Why would a responsible Java programmer want to use a nested class?
+ d4 w4 f/ O+ d  S6 Z2 ~' sA. To keep the code for a very specialized class in close association
+ u3 v/ R6 Y- s; |7 q' g6 Dwith the class it works with.7 L4 D8 ~, p+ I1 Q) }% _
B. To support a new user interface that generates custom events., W' A/ d/ ?+ P* j" y
C. To impress the boss with his/her knowledge of Java by using nested
) t5 Q2 I0 b: Y& u* X5 H, N3 O1 g0 lclasses all over the place.
$ A+ m/ {  H! x8 {+ NAB.. R7 M) I0 p3 e: M" g8 Q
11. You have the following code. Which numbers will cause "Test2" to be! v' \# _! m6 S' f+ q
printed?
, [* J' _; q" Rswitch(x){
6 y' W; V% [: [, G7 {/ v7 h$ Kcase 1:5 }7 O! O# H! v+ h5 v: I
System.out.println("Test1");& q! I* G2 i6 N* C; Q
case 2:$ K/ z1 t* x4 f! m( D$ y8 S% w, i
case 3:7 k* G% C8 G1 H' o% d
System.out.println("Test2");9 m( ~" w& @0 @& B$ q0 u
break;$ t. n9 c# T$ D; M
}
  \7 r' ~; R- _% h& YSystem.out.println("Test3");7 I" @( c6 k7 w
}
% G  a. M& N, s% ~7 `A. 0
# v. I. w2 O- [" ~. eB. 1
( G0 H! g3 A) Y! S1 i& PC. 2% k# T7 x& G. V7 {
D. 3
3 F! B" D- w4 K8 k. L4 @E. 4* @5 _9 r0 z4 l0 r
BCD.
8 `& E' W" s( k' _8 s; h9 S12. Which statement declares a variable a which is suitable for- _. K$ t; P( n. V
referring to an array of 50 string objects?: R* w0 M8 d- L  S+ o
A. char a[][];' o. S) X& W# }* M  Y4 I
B. String a[];
7 a* m4 Z8 ?% T) uC. String []a;4 J( r# C3 }! J. H& e( }1 j8 a# n
D. Object a[50];
4 L  @) B4 Y# v, g- g- PE. String a[50];
  Y& T2 D; g2 W9 d( j) CF. Object a[];) V- J! A  Z6 h& p
BCF.
4 H0 ]8 m% Z  W2 e: L! }! H13. What should you use to position a Button within an application1 K3 j" g$ H+ r( l& i# Q1 C9 Y
frame so that the width of the Button is affected by the Frame size but
* C! r% {+ @3 ythe height is not affected.
5 V" m2 Z! B6 Z3 @" R! j/ BA. FlowLayout
- L6 _+ r- b' z' z) ZB. GridLayout
' {- t  g5 _/ o" C* [C. Center area of a BorderLayout
  m3 m: e; r8 v7 ^8 YD. East or West of a BorderLayout
# z8 H: n, H& p6 j* HE. North or South of a BorderLayout4 I! v: K, p+ y. U: W& q& v: r
E.
4 K- V9 Q4 F6 X" E14. What might cause the current thread to stop executing?
& b) p6 p# C# Y2 a) A: g0 UA. An InterruptedException is thrown+ F: w6 l# c6 k2 Q
B. The thread executes a sleep() call% K6 Z/ |, Q1 z& R
C. The thread constructs a new Thread
7 e* x# M+ o2 F0 U, S3 m# H5 zD. A thread of higher priority becomes ready (runnable)
4 K. ]7 `- R- Q- |E. The thread executes a read() call on an InputStream1 V2 K3 i7 s0 `- ]5 {
ABDE./ O- A3 |' z' E" H- b
Non-runnable states:% z& {) L  B: u6 Z" U2 |
* Suspended: caused by suspend(), waits for resume()5 R: u5 r( ~) y9 h" z6 z4 c$ r
* Sleeping: caused by sleep(), waits for timeout
" n9 l. Y+ M+ K" H1 F$ A+ n* Blocked: caused by various I/O calls or by failing to get a monitor's
# c% C0 V# b$ q/ x; H; W4 h1 [, {lock, waits for I/O or for the monitor's lock6 C( J8 @' V. O2 `; |
* Waiting: caused by wait(), waits for notify() or notifyAll()
( x/ B. x+ p. f9 [; x. n: s* Dead: Caused by stop() or returning from run(), no way out  u# C* D1 W4 l' R0 A0 B2 t$ Z7 k9 [
15. Consider the following code:/ d/ \, @2 i# {1 v0 t! a
String s = null;& o. l9 s3 ~4 U2 E, d$ [) v( p
Which code fragments cause an object of type NullPointerException to be
# v2 E! t+ i/ P7 |9 P3 hthrown?4 {8 W; w8 F# u- U( b8 V3 w
A. if((s!=null) & (s.length()>0))
: A2 c4 t+ B- H6 O9 qB. if((s!=null) &&(s.length()>0))  W# Z) t% v9 k  g% v
C. if((s==null) | (s.length()==0))( M* s) N/ {" ~6 X
D. if((s==null) || (s.length()==0))$ S8 p2 @. M- X. A& ]. `! e6 w' U
AC./ R/ `3 x- m7 M2 j
16. Given the following method body:+ L2 S6 \" b' b# _9 X- ~
{4 ?6 ]9 Q7 l7 Q3 W4 C: r
if (sometest()) {* g0 x# ?$ u; E4 V! z- i. Y
unsafe();+ w; T- D1 M6 }  p7 {8 [$ v" e
}
; j; O) ?2 L" I& ?else {
; U' P0 X2 B1 p+ d3 qsafe();. e/ y+ B2 }$ ^
}* i" S! {0 D3 a: B9 N0 I
}6 y- j2 H% W' p0 H; T7 c
The method "unsafe" might throw an IOException (which is not a subclass
$ `9 D/ D: k/ V: {- K( R. Kof RunTimeException). Which correctly completes the method of
& @  H: B+ M* D8 t7 x' ?+ v" e( g5 pdeclaration when added at line one?& X- Y2 N. `+ x
A. public void methodName() throws Exception& n; \' w2 Q( @* a7 L$ k: H' o
B. public void methodname()
; N2 c: T3 @) o* x; b9 }1 x: |* _C. public void methodName() throw IOException
5 \. ]5 L8 D4 ]0 QD. public void methodName() throws IOException! }# l" v" U7 H1 k+ N
E. public IOException methodName()
2 E6 g# T0 R1 |) dAD.) j6 Q0 {) r# G  Z5 ?
17. What would be the result of attempting to compile and run the* G, b0 F9 ]$ M2 i4 @
following piece of code?( p; O4 \. ?% t: }  g# L; ~/ p
public class Test {
7 Y5 }8 F; Q1 B( T% t, X/ c" L1 ]% ~* Istatic int x;' i! `+ U& |3 J  ^
public static void main(String args[]){$ Z% h2 |4 C# G
System.out.println("Value is " + x);
0 O: E& v3 U2 h; [5 G}- ^5 I) h- f- v+ G
}/ X9 `3 Q; H2 l  g% g
A. The output "Value is 0" is printed.
+ f. q; `8 ~6 z4 r, YB. An object of type NullPointerException is thrown.
8 o2 u) M5 N" S! t1 vC. An "illegal array declaration syntax" compiler error occurs.4 a; y" p: l* v+ ?' V
D. A "possible reference before assignment" compiler error occurs.
2 z% O8 x! K' T1 uE. An object of type ArrayIndexOutOfBoundsException is thrown.1 e9 p! G. n+ h
A.+ c  X) I3 \' M1 Y. |+ D/ Z
18. What would be the result of attempting to compile and run the
" p+ d# Y2 h! u/ H+ Afollowing piece of code?2 o9 H. w* i6 r' p
public class Test {
- y3 b$ p/ T' ?6 W( p( [public int x;  ^0 _3 l2 x4 k3 x% C  v
public static void main(String args[]){8 J) [% H0 B$ g! ~; ]+ T6 g0 S
System.out.println("Value is " + x);
0 A5 q0 @. @  N- p0 O  U: g}
. U+ {" w( ?7 c2 l5 [}: o" B* H+ C+ X6 E9 ]- u
A. The output "Value is 0" is printed.
. |" A0 {& K0 m' J+ q% gB. Non-static variable x cannot be referenced from a static context..
0 Z6 E  c5 K- ?+ M# n5 tC. An "illegal array declaration syntax" compiler error occurs.
. E' F( d2 [) @. n! ?. ^- q+ C. O9 ?D. A "possible reference before assignment" compiler error occurs.- J; V8 j. C, n, t! }5 L( A" T8 A
E. An object of type ArrayIndexOutOfBoundsException is thrown.1 E8 v5 A! v7 b2 o5 ?' z2 b$ W
B.
1 r  e3 F# s: V4 D- n19. What would be the result of attempting to compile and run the! y+ D) t0 t3 {! Z+ [
following piece of code?% X# E" f: G+ j3 _! `
public class Test {
) H$ V* G8 `7 [  q# D% Jpublic static void main(String args[]){9 V: ]9 M0 K2 ]  V. O, X/ Z
int x;
+ X$ s# D6 H* i9 H+ m" }) h4 mSystem.out.println("Value is " + x);
; z; I5 L8 D8 _}
5 V+ K3 J6 N) t4 u0 N+ v}
; x# I1 z& |) \A. The output "Value is 0" is printed.
7 x# G! q3 _7 i8 b' R8 ^B. An object of type NullPointerException is thrown.7 y  G: P" {0 e# [
C. An "illegal array declaration syntax" compiler error occurs.
3 O# _1 {* E2 s4 g  O" rD. A "possible reference before assignment" compiler error occurs.
/ [! i% Q1 E7 B; B3 f* X* K/ ]2 ]E. An object of type ArrayIndexOutOfBoundsException is thrown.
+ Z/ K2 }4 H' U- x6 rD.
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

QQ|小黑屋|手机版|Archiver|联系我们|JAVA中文站 ( 浙ICP备12034637  

GMT+8, 2018-12-20 00:42 , Processed in 0.696924 second(s), 31 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

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