a我考网

 找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 87|回复: 1

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

[复制链接]
发表于 2012-8-4 12:33:16 | 显示全部楼层 |阅读模式
question 29)
% |* {, b; b0 l6 {* k. P" m+ Dwhat is the result of the following operation?   z- X  P$ E0 s4 W; r4 e
system.out.println(4 | 3);
/ N( {0 _. [! ~3 }1) 6
: V& @" ~% K+ v. M, A; b6 O2) 0
: \- e! O7 q7 h% z0 n3) 1 - b6 \8 d1 P$ w' W! D) r' z
4) 7 " L8 |, @+ [4 @3 M* x: t/ x1 V
answer to question 29
8 j* t/ H) z( F6 w0 _- W2 g+ o7 T--------------------------------------------------------------------------------
. K, @) E/ W  t4 @3 m* h! q* Bquestion 30)
8 n0 s$ q' g: U9 i8 p) |public class myclass1 {
) g: z* n$ q8 hpublic static void main(string argv[]){ } : A2 k5 h8 }1 S7 O: l: }7 H
/*modifier at xx */ class myinner {} # M: S$ [+ ]/ ?" h0 A$ ?
}
3 D. s$ o# c; |% @what modifiers would be legal at xx in the above code? * H5 V7 B& q0 ?: {
1) public
% Z9 R2 F* [9 H; V2 B2) private ( J" c8 P) f5 z1 ^4 ?# X! c
3) static , _0 n! S% C' y& U5 x
4) friend
, Y5 v, ?8 K* U6 panswer to question 30 ! `  o0 M* j# s3 F' L8 p$ P
+ B( [. L) b! u
--------------------------------------------------------------------------------
; B' i6 r$ m5 y3 N8 r) Vquestion 31)
6 a5 V4 \. J  A: K6 Twhat will happen when you attempt to compile and run the following code?   p; j, L- d5 N! g4 o; U8 X
public class holt extends thread{ - t: V& ?+ T  j. N0 y& |6 h1 O
private string sthreadname; 5 t' s2 Z, V- C0 M. \8 _+ d( S
public static void main(string argv[]){ : m  K. I! k: X6 i, N* k6 |
holt h = new holt(); # W+ g( x6 Z4 ]& D8 Q
h.go();
1 k/ Y" a# }$ q; P7 {/ r4 T} " s3 V" a. O, v' i6 F
holt(){} ) h& a* G, ~- B+ a3 U
holt(string s){
4 D' r+ T0 z) x/ F  Tsthreadname = s;
( h# H& h& r" `. S  O; b} 5 E3 r3 L9 V9 g: }$ s
public string getthreadname(){ # T% Y% |8 b% @, ]" i
return sthreadname; 0 T" _8 t" T- [3 X6 e
} " i/ ?' B( Q& L( ^9 Q
public void go(){
0 f4 l1 B8 W1 r2 b# j! l) aholt first = new holt('first');
回复

使用道具 举报

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

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

first.start(); - B$ f1 b; b+ F9 P9 V
holt second = new holt('second');
1 `! @! O9 B1 \  F/ h2 b: N1 ssecond.start();
, {# f- `- W" R" Y3 q/ l1 ~} $ l1 V  W& T: G/ \6 K
public void start(){
4 ~) p; v: s) C" p( h8 o5 G: Mfor(int i = 0; i %26lt; 2; i ++){   P% b/ {. N% t4 J& Q  v: b7 C
system.out.println(getthreadname() +i);
0 B* {; x9 |4 I5 U0 h- {try{ $ z/ P5 q( Q8 w/ Y; B3 Z' }9 k$ o
thread.sleep(100);
5 Q  H- R/ k8 o( r' a  w} catch(interruptedexception e){system.out.println(e.getmessage());}
6 r) v% h0 |# I+ R8 o}
/ ]$ x9 E3 Y! ^7 k* K! U} ( n; h( y( e9 A/ J. H
} </p>
5 q6 `7 W+ |* S1) compile time error
9 C% \' w: C  H' t2 E' _# U% `' j* O2) output of first0, second0, first0, second1
2 U# `$ U6 n# ]4 R8 j* `, j& ]3) output of first0, first1, second0, second1
, }' n1 N# W. }' s4) runtime error " v1 e7 E0 |* }* e  A
answer to question 31
* R& A/ o- Q; g8 d5 x% M-------------------------------------------------------------------------------- # P; a; H" A5 Q- \, X- A, V6 M  s
question 32)
% ?% a3 d& w5 C' Q# {- e" \an applet has its layout manager set to the default of flowlayout. what code would be correct to change to another layout manager. , p2 n7 u" w, _& B9 U
1) setlayoutmanager(new gridlayout());
4 r0 s: c  q& C  [# Z  f# s2) setlayout(new gridlayout(2,2)); 1 s$ b& f' p1 M+ b* y
3) setgridlayout(2,2);
4 |; [8 d6 i1 E" d4 f/ W6 o2 [, ^4) setborderlayout();   w% j3 k5 o0 D9 j1 }$ n, b: u1 S
answer to question 32
8 Q# _/ B! Z7 C; I' B# d9 @-------------------------------------------------------------------------------- / F: Y) B2 B4 ~4 R* g4 B
question 33)
  ]  |) |$ S6 |- hwhat will happen when you attempt to compile and run the following code?. & e8 e* H1 T9 B6 p! W& T* ?
class background implements runnable{ " a1 ^4 N/ C; G$ Q6 X7 H
int i=0;
% C) d" t% e! P3 x5 r6 Z% R3 tpublic int run(){ ! c* ^$ R) E2 Y
while(true){
回复 支持 反对

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-6-10 11:55 , Processed in 0.340735 second(s), 24 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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