a我考网

 找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 86|回复: 1

[考试试题] Java认证模拟题及分析(3)

[复制链接]
发表于 2012-8-4 12:33:16 | 显示全部楼层 |阅读模式
question 29)
3 g. m: F- N+ Y- i. Ewhat is the result of the following operation?
* ^0 b* N7 N8 T+ J9 c& A9 `system.out.println(4 | 3); ) i3 a6 @" [/ R( p9 k' l$ W
1) 6 ; d* X- u3 Y+ ~& u6 B/ Z3 O. @$ _
2) 0
6 G# `- Q- b+ i2 [% g7 S* |3) 1 7 F7 O  }$ l& [/ w! x
4) 7 # ]8 P1 O, {# L& e+ x
answer to question 29 1 y0 K+ [# ^* O9 H: c/ L$ ]
-------------------------------------------------------------------------------- * m3 n+ ^6 g- R+ G
question 30) 0 b, g3 w! b5 _9 c
public class myclass1 { 3 E, J& M- F- a0 E2 n" Y. Y9 B
public static void main(string argv[]){ } 7 f5 c2 _, p! G
/*modifier at xx */ class myinner {} * |6 ^5 e' a/ ?5 D; g; _
} % J, O+ i0 F- u* g# c
what modifiers would be legal at xx in the above code?
3 M  r% H- x5 T; _; e7 ]2 Y1) public
4 \$ k8 T9 W- \$ h9 R( s. D$ y2) private
/ U! j/ n$ F* P! u1 }7 p3) static
3 Z6 B% u% o; X5 C0 Q4) friend
- Q1 l& v( n* ~  Q1 f% a) Kanswer to question 30
) y% s; A% L; ^6 x6 _, P% ~- k/ O. a' x4 i# M' v9 B  A7 i
-------------------------------------------------------------------------------- 3 O5 S3 o* Z; l$ V4 o/ G
question 31) & s( _6 V' u) g7 Q
what will happen when you attempt to compile and run the following code? 5 O# M$ ?0 G5 K* N; e  k! k' L
public class holt extends thread{ 0 {8 D; {" M! q5 T1 i/ j
private string sthreadname;
4 t! I7 t% o3 d7 y- ipublic static void main(string argv[]){ : u( j" n8 m' N- M
holt h = new holt(); 4 c; e( f' {' O3 s- b( Z
h.go(); 3 ]% L* u- v/ a3 R6 P
} ' b. i$ |8 C- [+ C+ y* u$ [
holt(){}
' [$ d2 o8 Y+ E4 I5 j1 `8 Xholt(string s){ 8 H. E7 ~/ d8 y/ r: G' u( {% n
sthreadname = s;
! t0 t! D3 N  C}
+ s: U8 i/ |) a( x6 Wpublic string getthreadname(){
* g% [1 I- |* z* s9 zreturn sthreadname; * j9 ~; y: |! w; a; V- v% x
} 3 l. w& Y. t+ u- J, X1 \% K
public void go(){
+ j/ x: ^2 d) D! `/ b( D4 ^# _8 ]holt first = new holt('first');
回复

使用道具 举报

 楼主| 发表于 2012-8-4 12:33:17 | 显示全部楼层

Java认证模拟题及分析(3)

first.start();
) d0 ~' b0 v  p" U5 ~holt second = new holt('second'); ( q1 F6 O! L  R1 E# _1 [2 `8 P. E- B
second.start();
/ f  z; M& Z& X1 m, @3 W2 Q2 L} 0 \+ i. z2 S! Y* J& @
public void start(){
+ O% P, L# R: N3 Nfor(int i = 0; i %26lt; 2; i ++){
1 [+ Z4 D- P1 S/ I( ]4 j! msystem.out.println(getthreadname() +i);
+ s! q6 X4 k/ y! W4 X& Qtry{ 9 k! Y5 Z) j. c. S8 s' Z
thread.sleep(100); " O% J* i" R9 f) n% z5 C
} catch(interruptedexception e){system.out.println(e.getmessage());} - Y. f. w- P9 w$ }- V. A/ n3 b
}
: U! k9 F6 f) K! p; I) F6 n% I}
6 N$ J8 c$ r! X9 W" H; Z8 `: w} </p>/ ]/ x6 v2 A: r# F! z7 s) x. @2 }
1) compile time error
8 c  T' U) S" ]2) output of first0, second0, first0, second1 9 W  _6 q$ _5 x9 H
3) output of first0, first1, second0, second1 / J( ~) {4 m) e+ U% b" z, {  L- D; P
4) runtime error 1 J& j& f; s+ G  \+ Z: w
answer to question 31 + |5 P# R% j' _8 Q1 e, ?: z: O2 b# [
-------------------------------------------------------------------------------- ; O+ B; M; C# l5 l8 P6 P% v' y: J2 ]
question 32) ) I* @/ ~- I2 I4 I# F" b2 c! t5 h
an applet has its layout manager set to the default of flowlayout. what code would be correct to change to another layout manager.
; @$ n% {2 z- B8 i& e( W1) setlayoutmanager(new gridlayout()); ' h3 c2 p$ z, v$ }1 W3 Y# g, E
2) setlayout(new gridlayout(2,2)); 9 |0 y" B* ~+ J% U# m- h
3) setgridlayout(2,2); * j  [' l  C9 Z6 a& J
4) setborderlayout();
4 c+ l: z* g. e4 P' i( ]answer to question 32 7 o. u  q: p6 Q0 a" B  s. j: d
--------------------------------------------------------------------------------
& i3 ~! E" w% o; H1 cquestion 33)
( r! }0 m$ i  H' dwhat will happen when you attempt to compile and run the following code?.
/ M0 ~6 i4 Q7 N( X# eclass background implements runnable{
, r6 l% C7 |) g0 [int i=0; 1 G; S' F3 v( O. C1 @5 w' U$ f
public int run(){
0 q5 s+ M, o! g& \2 Zwhile(true){
回复 支持 反对

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-5-19 03:02 , Processed in 0.165625 second(s), 23 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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