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

JAVA中文站

 找回密码
 注册会员

QQ登录

只需一步,快速开始

扫一扫,访问微社区

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

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

[复制链接]

该用户从未签到

发表于 2009-1-4 14:18:59 | 显示全部楼层 |阅读模式
这是SCJP的考试原题,是1999-2000期间的!提供给想考SCJP的参考!' g" ~5 h2 K8 p, ]! @- Q9 I
    我这还有其他的一些,如果全部打印可能100多页(双面)的样子!我将陆续的在这里粘贴出来!(如果可以的话),一共分为几套!这第一套只有19题,其他的几套有点多,300多题的都有,我归纳的,我同事说看完了它,考试就没问题,所以我就搜集了这么多,我也看的头大,所以发出来给大伙分享,敬请关注!!
4 i0 X- a% r% p: l5 g. m: c& n2 `8 D1. Which statement are characteristics of the >> and >>> operators.
1 N5 o9 @  y% i1 FA. >> performs a shift& W- T' q9 Y+ a& I3 |2 [
B. >> performs a rotate
$ P9 Y: ~( _/ e* W7 k5 wC. >> performs a signed and >>> performs an unsigned shift# ]0 C1 A: z: i- n& T
D. >> performs an unsigned and >>> performs a signed shift
2 v; g, ]' k9 p% L- w0 vE. >> should be used on integrals and >>> should be used on floating7 d/ h$ R- s2 R: T
point types
7 _; _$ e# M$ I6 j9 I( B, @) T  e9 O; OC.6 n0 M: f9 V/ E7 Z9 N# V
2. Given the following declaration
3 q* Z4 Y3 r/ f5 X, B# dString s = "Example";
. |0 E6 ~/ k& Q0 j1 j. V" I* aWhich are legal code?" e" O: f" \# j# y5 |
A. s >>> = 3;5 w9 S, L' s1 E& i
B. s[3] = "x";
% h7 W/ \! M, D" \( dC. int i = s.length();6 c% t" {6 f/ \; ~# ~$ Z
D. String t = "For " + s;
/ y# N) d$ @% uE. s = s + 10;
" k) d5 |- [/ A- G9 f3 a4 JCDE.& M" z' v- X* {  m  J/ u. _
3. Given the following declaration
0 i8 K, R: B2 t+ T8 C9 ^8 u: `String s = "hello";
9 A: ^* M/ p- c/ }6 [8 ~Which are legal code?
: X( J/ n  j# u% N+ p3 ^; ?A. s >> = 2;" i0 D, N+ F2 ?; f; R
B. char c = s[3];
: \4 F7 a. F2 }  K# p, w5 dC. s += "there";' N6 V& V5 k4 r  y/ ]" ^
D. int i = s.length();
) s7 J0 P! V) G+ Z* RE. s = s + 3;
; p" i6 ]. o9 }9 XCDE.; }* a( ~# i* r3 f/ \( w2 P  r& u
4. Which statements are true about listeners?* k& |: s: c; r. O8 N7 R! z
A. The return value from a listener is of boolean type.) `) s" c9 E6 O$ Y7 k4 ?
B. Most components allow multiple listeners to be added.
- }' s0 i% Q# R) j% ~- P: u2 d$ CC. A copy of the original event is passed into a listener method.
; k% K* ^& s. rD. If multiple listeners are added to a single component, they all must4 ]9 E/ ~! C1 ?. x( j
all be friends to each other.8 ^& G1 M9 R( ^3 V9 E2 @) X+ V
E. If the multiple listeners are added to a single component, the order
3 m2 v$ X% |9 o* P[in which listeners are called is guaranteed]., N% g8 g; s5 N# U
BC.
' U$ M/ ^' O5 ^9 V' V; u% }, k5. What might cause the current thread to stop executing.- T1 U; @- W4 t, M- V4 c! f( T( n
A. An InterruptedException is thrown.
! K+ V8 F$ `. R% W/ G5 CB. The thread executes a wait() call.
7 o7 d' ~8 _0 x/ CC. The thread constructs a new Thread." \; X6 y6 s: E( C1 m0 M
D. A thread of higher priority becomes ready., I: B+ n  q8 R* @3 N
E. The thread executes a waitforID() call on a MediaTracker.
+ R2 ~( ]; M7 GABDE.
) c4 e. P! X( ~: W- ^/ A# w6. Given the following incomplete method.) {2 K0 y+ @7 [$ U/ _; i- m+ _
1. public void method(){
4 H' C5 N( ^3 J, o/ k2., h3 w' @8 j- R4 w* I5 Y
3. if (someTestFails()){4 Z4 P6 P% F6 h% p5 D
4.; g7 ^% p; Z/ {
5. }. P3 w. P9 ]- H, m  h9 k
6.$ _  ^: J- F, |
7.}" e. J, Y/ P4 j/ |, Q
You want to make this method throw an IOException if, and only if, the" P! c& v2 h: G7 v7 J  S
method someTestFails() returns a value of true.! }9 `7 p0 L( K( S* [- |
Which changes achieve this?1 u* B$ z# o  ]6 e( n& r! |
A. Add at line 2: IOException e;. T( ^7 C) o. i6 G, V7 X
B. Add at line 4: throw e;
4 j1 ~+ s5 F' s% d* V1 h' jC. Add at line 4: throw new IOException();
# V; x4 y6 K" r1 ?/ X! `& B8 ?D. Add at line 6: throw new IOException();
3 {' Y- P, d8 B9 i3 B1 c4 [E. Modify the method declaration to indicate that an object of [type]% F) b! B0 }7 P  P
Exception might be thrown.
1 ^2 H, w5 q) S; ?' `" X) JCE.6 a5 |3 v7 @: ~, o
7. Which modifier should be applied to a method for the lock of the% q% ~# V& J# {( s9 o: E
object this to be obtained prior to executing any of the method body?. T7 x7 s# g0 m) h: H+ j: T5 ^- d
A. final2 z1 c) |! ^/ C6 t! r
B. static
2 p/ E0 J7 \/ J: QC. abstract, |( L* R+ G1 s! j9 @' V$ F2 h6 r
D. protected
$ E  l$ D: u. ?4 `/ }( K# Y& EE. synchronized
9 H1 j& Y) Q: H" t9 {4 ]E.5 }. Z5 x! [* p1 }& C
8. Which are keywords in Java?
/ u# I! T6 s5 _4 B) g8 H8 \' hA. NULL/ ~! j6 g- O2 j) f7 _. t9 f/ G
B. true4 F$ D7 d1 p3 k+ Q, H
C. sizeof
6 H' Q1 v) ^9 n- ]D. implements- l! u  ]; u6 U$ G
E. instanceof' c/ |. _7 |, B* `
DE.+ Y: [& V9 ~; ]* Y& `  U1 _
9. Consider the following code:& i& W# `9 l# O4 f9 V
Integer s = new Integer(9);
& u1 F9 y! t( ?( N) o8 W7 tInteger t = new Integer(9);2 F$ j0 U% \, j! c: t/ R
Long u = new Long(9);& J; D3 I0 P' K8 ?9 X2 p$ I
Which test would return true?2 k1 u6 a+ ^- _7 B
A. (s==u)
$ s+ i' A; C. C: }( Z* aB. (s==t)1 z, O; @% d- J- e9 k; q
C. (s.equals(t))  @& O  Y, z! h4 E: z! |# N& L/ |
D. (s.equals(9))! @/ u( t" l; K) I
E. (s.equals(new Integer(9))2 i& h. M4 s3 y; v( o; a* [" S
CE.
9 ]& ~' h$ i, S6 R4 |10. Why would a responsible Java programmer want to use a nested class?
! P& L9 W7 L6 G+ wA. To keep the code for a very specialized class in close association
( E+ i2 k# w1 X2 @2 [# p8 t4 Mwith the class it works with.
+ a: G* D0 {2 }5 q/ CB. To support a new user interface that generates custom events.8 D" `+ k7 [" G- L. ]" ~( h' ~' ?
C. To impress the boss with his/her knowledge of Java by using nested
2 T; p+ B& Q8 P! L' v; K& wclasses all over the place.# V- u) ]- R2 m/ o% h
AB.! S; p: \5 m- M1 l0 L$ U1 e. t
11. You have the following code. Which numbers will cause "Test2" to be9 ?) U. v8 C0 @4 F( O9 e' j( ^3 X
printed?& w/ `/ A% ]' E" k/ y7 S& M, J1 M
switch(x){& ^" j; f; N6 k- d  w' A
case 1:& j% U# \) ^% Z
System.out.println("Test1");+ U; K$ l3 J+ _/ G
case 2:  w2 S" H  |4 B  x
case 3:9 Q7 W& O3 [4 \* a3 f  Q; _
System.out.println("Test2");% T. }( [8 A6 w- J# E6 D* l1 \
break;* E$ c% m" C7 e$ h  o8 ]  p
}
" Q) q% C7 q( o# ]: E& j/ ASystem.out.println("Test3");
. N& R5 H! M9 E: T3 @; D8 @}
0 V5 o, }8 J7 L8 I2 q' O: C, xA. 01 V; X3 ?0 @& C3 A. n4 }; Y
B. 1
! V  F! e# l9 gC. 2
* c( t( C, X4 b4 d, OD. 3
; C% E' Q8 m# [* d. z: s0 cE. 4' V3 `% A! E4 q) C
BCD.; h4 K- h- V4 F0 y/ e+ b$ S
12. Which statement declares a variable a which is suitable for
7 g/ c1 K8 V1 F% e; N( e$ qreferring to an array of 50 string objects?
5 O/ r8 h9 G- ^. R* y/ k( BA. char a[][];
" I9 j9 m8 q3 TB. String a[];& A* y2 g# H) e; f4 r3 F
C. String []a;6 j2 S# g/ O& e0 j) C  @: `
D. Object a[50];2 `) \( |0 ?% O. d! C! P
E. String a[50];9 e% {4 M9 P& G& k) M( p# f
F. Object a[];  t6 c2 @8 f. f) n" v5 b
BCF.
' |, o# r, i" _13. What should you use to position a Button within an application
5 j, v$ \& `/ I( ?# ^frame so that the width of the Button is affected by the Frame size but* i! z9 z, D1 {, j9 R& ]6 z
the height is not affected.9 U) @: `8 g! V: [
A. FlowLayout
) t8 g. K/ K7 s, `$ mB. GridLayout# X0 S2 w# p3 V; K
C. Center area of a BorderLayout/ e% ]% z& L5 {2 O6 o
D. East or West of a BorderLayout
' Q* d) f+ i( x# z) I' i% JE. North or South of a BorderLayout
: v0 ?" b* ~3 ~" Q- [" aE.
. i8 x( O! j# p# O& |2 t14. What might cause the current thread to stop executing?, s- h7 N( ~$ N6 R- U6 x
A. An InterruptedException is thrown6 m- w  P9 w4 K1 j) G: [
B. The thread executes a sleep() call
' ]9 H% Z3 h3 J0 R! ]% T7 PC. The thread constructs a new Thread
8 R/ ~& q% M/ j) nD. A thread of higher priority becomes ready (runnable)0 z. C/ v$ N4 K9 G0 I2 y
E. The thread executes a read() call on an InputStream
: F0 o. K+ G' H( x' Q0 X$ M7 F1 JABDE.& h. u2 U0 J1 b% w
Non-runnable states:6 }, i, r9 U4 g! P  S0 q
* Suspended: caused by suspend(), waits for resume()4 G7 g, _1 S9 E, c* H# w
* Sleeping: caused by sleep(), waits for timeout0 g3 v- _; K3 v9 V' P" A1 }( A
* Blocked: caused by various I/O calls or by failing to get a monitor's
+ `! C. g7 s4 Olock, waits for I/O or for the monitor's lock) Y+ H0 z% N. @2 X9 o( k$ m" n
* Waiting: caused by wait(), waits for notify() or notifyAll()
) ~: ~% D( ^0 E" c; ?1 Y* Dead: Caused by stop() or returning from run(), no way out/ ^  i5 O* R3 k0 x# n
15. Consider the following code:+ B3 F4 f. H- U, n
String s = null;
6 D4 k* O1 N& n8 Y% H7 NWhich code fragments cause an object of type NullPointerException to be
8 L. K3 \5 K* i  H4 M( \7 }! v4 kthrown?: u& \) ]9 B' o
A. if((s!=null) & (s.length()>0))) ^* k" f' W; n6 M0 |
B. if((s!=null) &&(s.length()>0))
6 f/ @) c4 Z/ b. u. JC. if((s==null) | (s.length()==0))& T+ n' \: k" b5 F3 p! R+ [' \
D. if((s==null) || (s.length()==0))
4 w( c2 }1 V' n5 Q$ Q2 pAC.- U: z7 J# h/ x7 _0 M# U
16. Given the following method body:' v+ p$ \1 D% ~( A9 b
{# s. N9 g, L7 H9 ^: ~
if (sometest()) {) K1 y: r( r/ m  ^" d
unsafe();  `- K* Z5 h' h4 g0 a. V6 t
}" K! R: G$ X: h( w
else {  y5 z' O# A$ z: B, T! g/ [8 B. O3 ~
safe();
5 v) X: b3 K' f0 N}/ Z. `; W: h( s
}
0 X, M! O  u. a( J7 \The method "unsafe" might throw an IOException (which is not a subclass/ j2 X. h5 s3 J" F* O6 }
of RunTimeException). Which correctly completes the method of
! G0 J7 o: j: q' Kdeclaration when added at line one?! e1 n  h; k( a7 k
A. public void methodName() throws Exception$ V$ e# A' p, V! E1 C
B. public void methodname()
9 K0 x1 c8 Y+ ]' |0 bC. public void methodName() throw IOException
' k+ m- J0 g. J) {: `D. public void methodName() throws IOException; {. ]5 q7 y! m( R
E. public IOException methodName()1 I! A+ D" f) L6 b; H3 e1 x9 F
AD.
5 O$ {% G- g, [17. What would be the result of attempting to compile and run the
! d9 C5 Q5 c6 A7 o0 a5 L# xfollowing piece of code?
: [  r6 }; K1 `( @  Apublic class Test {
( Q" ?- ^# z1 n0 n/ U5 _static int x;9 `, O% ~/ b' D2 x3 F7 S* e
public static void main(String args[]){3 O  a2 r3 {2 \% l* s" e9 G
System.out.println("Value is " + x);* p! A" e/ A$ P/ {' u  E
}, p$ C' z% m( a& d6 {- _
}% i! }! o& k( W, a% d  R+ h
A. The output "Value is 0" is printed.
; n8 k1 X9 F* @' f* OB. An object of type NullPointerException is thrown.
6 r' G4 O1 b0 m" Q" }C. An "illegal array declaration syntax" compiler error occurs.( c, x  k9 G0 N) }8 |- O7 G2 ?
D. A "possible reference before assignment" compiler error occurs.$ E9 V1 K3 U3 `# ^
E. An object of type ArrayIndexOutOfBoundsException is thrown." k) U. R+ j) a0 N/ Z. r: O( k/ m
A.
4 X  `9 l* z, }18. What would be the result of attempting to compile and run the
2 ?, ?5 Y) ]0 q/ n8 w, ofollowing piece of code?% F5 I  O7 j; m* I4 ?
public class Test {" j8 d& Q9 m8 c$ M1 A3 z
public int x;; t& V, x) t4 W0 l
public static void main(String args[]){
: k6 M: a. \/ n& J( `8 bSystem.out.println("Value is " + x);* X5 o4 W1 P1 N; d3 y5 l
}4 ]- K: X' r# J$ O* A
}; ^' V! n  [: g5 J4 \: g
A. The output "Value is 0" is printed.
) Z7 w* @) p8 n6 }B. Non-static variable x cannot be referenced from a static context../ F1 h( L5 `; @+ e) O" w* M
C. An "illegal array declaration syntax" compiler error occurs.
: _' P# a6 N2 b1 O& E( PD. A "possible reference before assignment" compiler error occurs.& o% w1 n% ?# H1 O
E. An object of type ArrayIndexOutOfBoundsException is thrown.# k8 p/ Y# d. g" G( M
B.
4 D" [8 k+ h$ P$ z9 y) j19. What would be the result of attempting to compile and run the
$ T! m4 v+ V/ i* F& ofollowing piece of code?
% r; A9 x- g, lpublic class Test {
! @* F7 v2 d. x+ _; y9 ipublic static void main(String args[]){
* g8 F/ T8 s* t0 |/ P8 [0 X& ~& aint x;
. w; s( i+ o2 k2 k0 H; gSystem.out.println("Value is " + x);
. \' h0 t* D: [6 O9 c; a5 E6 p+ r# P}& t7 {3 ]  y/ j" x2 U
}& w, @9 U+ u7 i2 g
A. The output "Value is 0" is printed.
9 ~2 {- q& h8 ~; YB. An object of type NullPointerException is thrown.
+ G, J1 f( R- K0 m' F& SC. An "illegal array declaration syntax" compiler error occurs.. X& E0 h  M9 N$ F( j
D. A "possible reference before assignment" compiler error occurs.
2 z4 p6 Z/ o. Q- f# R. C- t' ]E. An object of type ArrayIndexOutOfBoundsException is thrown.
" M9 t3 Q1 ?# n  l5 u9 YD.
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

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

GMT+8, 2018-2-11 16:16 , Processed in 0.458445 second(s), 29 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

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