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

JAVA中文站

 找回密码
 注册会员

QQ登录

只需一步,快速开始

扫一扫,访问微社区

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

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

[复制链接]

该用户从未签到

发表于 2009-1-4 14:18:59 | 显示全部楼层 |阅读模式
这是SCJP的考试原题,是1999-2000期间的!提供给想考SCJP的参考!8 h) Y3 X; c, q& v
    我这还有其他的一些,如果全部打印可能100多页(双面)的样子!我将陆续的在这里粘贴出来!(如果可以的话),一共分为几套!这第一套只有19题,其他的几套有点多,300多题的都有,我归纳的,我同事说看完了它,考试就没问题,所以我就搜集了这么多,我也看的头大,所以发出来给大伙分享,敬请关注!!
) n$ E! V( Y) r& s: Q1. Which statement are characteristics of the >> and >>> operators.* A9 v% m' u0 Z' @, j- [% ~' Z4 a
A. >> performs a shift+ P* V0 j' ?* w% m
B. >> performs a rotate
) {# x3 m( A( l: [' ?, C( Z& zC. >> performs a signed and >>> performs an unsigned shift
4 O5 W/ w2 X# U6 S6 _+ L* ~2 dD. >> performs an unsigned and >>> performs a signed shift1 v' y; o/ l. Y  x- Z  ^9 v
E. >> should be used on integrals and >>> should be used on floating
* l4 y' X- `( Rpoint types
- Y- X" j2 Y- v9 j/ ?C.6 O8 M$ [- l3 t" X; G
2. Given the following declaration
; C$ O5 E; n& _String s = "Example";
1 U) v( J& }% u: V+ GWhich are legal code?
& O! D, e9 h; ZA. s >>> = 3;$ q" ~3 x5 C+ @+ L" K" \3 E4 }
B. s[3] = "x";6 l: b) U" F0 {% C. d
C. int i = s.length();, y! J. z: I. n0 E- Z
D. String t = "For " + s;- e& \6 n& G- I
E. s = s + 10;
  w, o$ O' m/ aCDE.
7 H; G; `' x5 h4 i% e1 b3. Given the following declaration
% ]3 F+ J0 m  @' S# }String s = "hello";
+ L" \0 {4 g; N% {Which are legal code?0 M# N5 q& j, |; m/ M, b4 y
A. s >> = 2;1 S. Q$ b! p* M6 c: K; h* s
B. char c = s[3];6 G' q8 E7 t# k
C. s += "there";9 R: f1 m- o- z4 I& ~3 Q# V
D. int i = s.length();- m- z6 @$ @7 v
E. s = s + 3;
' `4 I4 N1 ]9 gCDE.3 ?. J0 U' P4 m" [1 J
4. Which statements are true about listeners?$ V3 s1 ]" t) m2 A$ O
A. The return value from a listener is of boolean type.
, A9 U) h0 u( rB. Most components allow multiple listeners to be added.
( C) \" [* }- i9 EC. A copy of the original event is passed into a listener method.
7 @" q1 }" W8 G( A7 ]6 [D. If multiple listeners are added to a single component, they all must
/ A% w7 N! ~! K9 G6 `! v9 b2 aall be friends to each other.9 n" D% E( T) o; w5 y) p( n0 I
E. If the multiple listeners are added to a single component, the order8 x8 E! S% R  w0 T. H0 M
[in which listeners are called is guaranteed].
6 m8 w2 P$ X' I( t! vBC.
! }2 O6 R; o% t4 S, |, ~& r5. What might cause the current thread to stop executing.
6 W4 O$ c8 Y9 u& D1 rA. An InterruptedException is thrown.
- f+ i, w6 [5 {6 p: D& P( W% zB. The thread executes a wait() call.4 _$ U+ d# F: }
C. The thread constructs a new Thread.
/ z4 N' j, ~/ }/ p+ xD. A thread of higher priority becomes ready.
) T# f5 |2 _* lE. The thread executes a waitforID() call on a MediaTracker.
' @: L8 z# o9 n/ D, U6 lABDE.
) }1 p) ?& p0 g# V6. Given the following incomplete method.& o7 s7 j& k6 l* h: ]/ C0 g
1. public void method(){
; g- c1 u, L8 D% D1 y, u2.  r  S, o6 ^3 H  g/ y3 L! F# }
3. if (someTestFails()){
3 L3 M; n6 p5 I' u. J! t; k( B/ q% U4.
1 i" s' M2 |: A( W5. }
7 l- @4 O- e  g% N9 y" r$ u6.9 ^/ ~* ]' {% t4 F, b2 \
7.}  @' s* N9 ]3 V9 N3 [6 @
You want to make this method throw an IOException if, and only if, the2 G0 f2 B; X7 X9 h: [- [! k- @' N
method someTestFails() returns a value of true.9 d  `9 m; E) ?% n
Which changes achieve this?+ j2 j5 ^$ c' K; F' Y2 W* o( N% o
A. Add at line 2: IOException e;/ p  M7 J# M1 E
B. Add at line 4: throw e;  q7 t8 C- {3 o/ d) B) k
C. Add at line 4: throw new IOException();( Z3 f, W3 A% `" d* l
D. Add at line 6: throw new IOException();
3 h' b. X% u( J5 \3 tE. Modify the method declaration to indicate that an object of [type]
: D3 K+ M+ v  v- F0 ~Exception might be thrown.- V8 K6 y2 t) X* J
CE.& m# A" F& C( ~& o) G
7. Which modifier should be applied to a method for the lock of the
4 ^  T! Q4 o6 z- Q: ?object this to be obtained prior to executing any of the method body?1 \5 @* j+ x. _) {4 q
A. final
( r0 v% j% l; O3 A( OB. static' W4 O& l2 w+ G+ t
C. abstract/ @' _, h$ n3 E! }) a
D. protected
8 x. ^+ f1 K, {( KE. synchronized
: [- O# u# e" @; wE.. M5 A3 F, O* J# y* G0 i9 m% F0 z
8. Which are keywords in Java?4 ^7 c2 S8 g  Q% j9 ?/ h. o7 W" L
A. NULL
* ?: s& |2 b" Z0 JB. true& E8 x& S1 ]: z' I- g/ A
C. sizeof' @% z, q6 P+ Z6 A  _
D. implements5 R. h, Q) T* F+ Z
E. instanceof
4 F7 Y9 l: A' I) v; kDE.2 |( E6 i, ^9 E! t
9. Consider the following code:5 e' a% O- H3 n( k( d# A
Integer s = new Integer(9);
2 g: N1 C# P8 {+ A( ~1 P1 J/ X* Y5 Q6 vInteger t = new Integer(9);" I- G, P& X/ b; G
Long u = new Long(9);' \. F# a9 c9 y* \) F
Which test would return true?9 M7 Y, J: c9 e" X
A. (s==u)
( J- g3 i: E6 [2 {: P5 D7 GB. (s==t)3 x3 L1 K' T) m& {$ @+ C
C. (s.equals(t))6 H6 ]6 f4 ?$ n+ W- ]
D. (s.equals(9))
& i/ U9 w$ u! k: [) c$ Q  }E. (s.equals(new Integer(9))& M8 l+ B8 b" t. h; }. r
CE.
' |6 N% C: t6 ^; M10. Why would a responsible Java programmer want to use a nested class?6 q# E# d5 v9 `  T* m% @
A. To keep the code for a very specialized class in close association
+ Y; Z, k# k7 F$ Q& fwith the class it works with.
+ _- Y0 S3 K: v& \* P. \& }5 M  pB. To support a new user interface that generates custom events.# D3 C- @3 H& \' l9 b; w) S
C. To impress the boss with his/her knowledge of Java by using nested) t# S" h# z* G# E
classes all over the place.
9 C; d) ?; d0 ~  `' B$ {  sAB.. q* h9 r% c3 }
11. You have the following code. Which numbers will cause "Test2" to be
1 H. O4 Z' h8 ]! |2 [9 _9 Jprinted?
, V2 I( u8 L/ S4 T% wswitch(x){: B0 k& E0 v2 g4 _
case 1:
! K, U2 U' R4 d% e+ H6 o2 y" SSystem.out.println("Test1");: Y# k5 X1 a3 ^( y& s0 S( o
case 2:
. Q, \1 @3 [9 {+ k+ \+ hcase 3:' M5 w2 E/ D  A- ?7 O9 l
System.out.println("Test2");
( b# M! m: g# L% M" u& U: Ybreak;8 o0 }3 s: T1 q. T/ O, _$ I
}
/ ]( K! n) s# d5 E) \System.out.println("Test3");
+ T" a1 [2 {; J  s}
6 i7 }2 q: s6 OA. 0
" h% ]( h; M1 l& V+ wB. 13 v2 j( S: l3 Y  O: p
C. 2% q1 g  N( z- W; R! V4 v+ }! L
D. 3; ]  @: s: Y( W5 V9 ~  l$ q1 K
E. 45 e# g* [: b; M& G4 z
BCD.
* V6 z0 `* n+ J6 C5 Y6 E, ?# `9 {12. Which statement declares a variable a which is suitable for
% U) q, v; a& y! \( w# dreferring to an array of 50 string objects?
% R8 b9 d$ R3 E& F, C$ g2 H- P4 O0 e) IA. char a[][];
, ]' R  E' z- |B. String a[];- Z9 X7 r6 M9 ^3 ^! ?; z3 y- w
C. String []a;
8 |9 K  ]. |' W- XD. Object a[50];
, o5 a$ W$ p% \6 k4 OE. String a[50];+ T5 e- P, \" F% S% f
F. Object a[];
6 Q, A5 i- u& ^  R" D% S  ~3 qBCF.
* u8 c! f) z2 V# k5 Z# L13. What should you use to position a Button within an application9 I$ M; {% s( s6 e! r  M# K7 M2 y
frame so that the width of the Button is affected by the Frame size but
& E  b1 {( N9 \' [& _/ ]* H$ Q: Dthe height is not affected.
0 i. Q* c4 h) T$ RA. FlowLayout) I; T' E1 T" V$ u' I) b7 ^
B. GridLayout7 c! |1 n+ Y1 I/ T9 T
C. Center area of a BorderLayout) y: S4 o( h2 I; f$ p9 G
D. East or West of a BorderLayout
! I4 f7 e; g- Z7 [6 k; l* VE. North or South of a BorderLayout
; _' U& C8 g$ a  {9 lE.
( L, [. f6 h. E14. What might cause the current thread to stop executing?" h1 e2 t5 n9 A2 d  W
A. An InterruptedException is thrown
# w3 o- J6 T; G( L- s" F4 j; ]5 YB. The thread executes a sleep() call
1 C4 z6 T5 c0 U6 L, R: yC. The thread constructs a new Thread& \# h9 {- l: V4 e4 Q+ h6 `
D. A thread of higher priority becomes ready (runnable)/ T( S: y8 j0 N/ f
E. The thread executes a read() call on an InputStream
' k% }/ D( K* h$ T9 Q1 tABDE.7 m& D" |3 p! A5 M( m0 a
Non-runnable states:+ {2 t2 {: e8 S7 f1 L
* Suspended: caused by suspend(), waits for resume()
- @; s4 \! \  Q* Sleeping: caused by sleep(), waits for timeout
8 `  O/ q/ E) l( ^- q% M* Blocked: caused by various I/O calls or by failing to get a monitor's
3 L5 ]$ K: n' u- S+ @8 Hlock, waits for I/O or for the monitor's lock
( Z: p5 V) l* E7 x3 n$ B6 U* Waiting: caused by wait(), waits for notify() or notifyAll()
5 I5 Z3 E- w) Z% g; C/ m( b% Q; j* Dead: Caused by stop() or returning from run(), no way out2 j5 M* |: c9 b# [/ r( V& H  H" [
15. Consider the following code:
0 g: P- u/ q% i" `String s = null;
: F8 Y  M1 S4 U8 v# Q! y. K$ E, PWhich code fragments cause an object of type NullPointerException to be# Z# m  `7 k+ E- L8 A$ T4 b5 M4 D
thrown?
6 C  M6 @- n  s/ E3 F0 M/ EA. if((s!=null) & (s.length()>0))
; N4 U" Z% H0 t$ X* UB. if((s!=null) &&(s.length()>0))
: B) m, S9 ?% T2 S) ZC. if((s==null) | (s.length()==0))% s- G* e0 J; K8 M* _
D. if((s==null) || (s.length()==0))- [' L8 ^  Y3 ]* _% x2 u5 s
AC.
$ q( e, O$ d( A* s' z- b4 P16. Given the following method body:/ K+ c. a4 a, {/ g
{
# o6 Z* _/ K7 b- n% pif (sometest()) {
, t! Q8 h, T) I# b( w! D6 tunsafe();
& V( l* r1 x3 J/ ^! n" a" z}
0 b9 y  M* {: Delse {* F4 h8 i/ V' o8 x4 j
safe();
2 f- a5 Q3 t' k0 Y' H1 q}
1 J. ~$ U8 G& j& C! u6 \% O3 u}
: u$ `6 H! D% N) W, J: ~0 |The method "unsafe" might throw an IOException (which is not a subclass0 w9 L6 p, ~7 }
of RunTimeException). Which correctly completes the method of
* R" l$ {1 T  l$ f- O; ~6 p- }declaration when added at line one?
8 Q7 c; ?' z0 u  [A. public void methodName() throws Exception& `7 ^' j7 \# x7 U
B. public void methodname()
4 D' X) G/ m& b" n; {/ H: R3 BC. public void methodName() throw IOException
6 w1 Z( a$ }  [D. public void methodName() throws IOException
1 U+ T: D; c/ o. f/ @' CE. public IOException methodName()6 Z, v" e- r& G$ b3 {# Y- \( A
AD.5 y. g/ w+ g9 v- f  T  u& I
17. What would be the result of attempting to compile and run the
( A1 y* ?/ v) ~following piece of code?% D8 L3 j( D7 C" B
public class Test {* l" V' Y  K  s! K
static int x;
& P  r* Q; H5 H* K* }public static void main(String args[]){# {+ W/ d& z3 @2 H, e6 _. g" {
System.out.println("Value is " + x);
, A( P! B+ T3 W, r, X}% V% s) }. }% L; k3 s
}
) [2 h* {7 ^1 G. bA. The output "Value is 0" is printed." h7 L; U; S: N7 q
B. An object of type NullPointerException is thrown.; w% t) G* Y0 w. j  y, u
C. An "illegal array declaration syntax" compiler error occurs.
* X- U# Z0 l- _% nD. A "possible reference before assignment" compiler error occurs.& `6 Q! c  t9 P2 w' [7 v
E. An object of type ArrayIndexOutOfBoundsException is thrown.
  A9 \: P0 H) I6 hA.9 X% |1 O' P0 o" E' Y
18. What would be the result of attempting to compile and run the' [' [1 z6 y3 y* R
following piece of code?- a6 t. O. q+ X
public class Test {
# t9 h/ @' W) l# i1 I# A( y4 p$ Bpublic int x;
- C: m( y( h. ~" Fpublic static void main(String args[]){
9 Q" `% o. H; S% j$ M. J( C: R$ WSystem.out.println("Value is " + x);% T# w8 V+ S- r% X
}* j( m! H+ u" F& ^0 U; ^, X
}  J2 I1 \9 g' Y, N( X4 r2 O
A. The output "Value is 0" is printed., u/ ^# v7 }, U1 w- f; ~
B. Non-static variable x cannot be referenced from a static context..
9 ?4 ^1 n9 f# }; Y$ b+ UC. An "illegal array declaration syntax" compiler error occurs.
. N( D# e! X5 y$ K9 Y3 HD. A "possible reference before assignment" compiler error occurs.
, @* x% r: G: M9 T, KE. An object of type ArrayIndexOutOfBoundsException is thrown.
+ `8 J. l% L$ D, M/ l  @: N& B9 dB.
% s. _4 V8 B  W6 {6 d. y) \19. What would be the result of attempting to compile and run the
" E! G( P0 Q8 z/ t7 kfollowing piece of code?
' {% X/ ~+ O6 D9 p( d9 I5 g9 bpublic class Test {
  g+ a5 f9 t. J2 d9 ]. A7 T9 I+ J0 vpublic static void main(String args[]){
3 P4 T! E$ }) t+ J2 k6 cint x;* H1 y  E! d+ S3 L2 I+ ~
System.out.println("Value is " + x);6 B3 W* I/ X' ?& g9 f; g
}
  @7 j, T$ q' j5 q8 Q}* W/ Z* y  Y- x; a# V; N- V* X
A. The output "Value is 0" is printed.. b2 W3 C; t7 a0 V0 z# E1 t
B. An object of type NullPointerException is thrown.
! I. K8 l7 X: D6 C4 u. `$ r* D7 S& [C. An "illegal array declaration syntax" compiler error occurs.
6 G8 ]+ l  ]7 V) G7 Y2 M7 pD. A "possible reference before assignment" compiler error occurs.
* L$ F- w" P* a0 i. e$ L9 jE. An object of type ArrayIndexOutOfBoundsException is thrown.: t* s, k3 A5 k7 c
D.
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

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

GMT+8, 2017-12-10 00:24 , Processed in 0.414494 second(s), 29 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

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