a我考网

 找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 120|回复: 1

[考试试题] java认证试题:Java认证模拟题及分析(4)

[复制链接]
发表于 2012-8-4 12:33:16 | 显示全部楼层 |阅读模式
 question 45   what will happen when you try compiling and running this code?5 q3 g1 K) f4 G4 Q. F
  public class ref{8 H/ p) D& Q" R2 _
  public static void main(string argv[]){
1 V7 W$ K  x' F0 K0 ]8 ]; a6 q  ref r = new ref();
' C5 v& ~7 C7 d' Q& j# C0 m: w6 V  r.amethod(r);. K# O- o* h) F
  }: _% l  B- f0 ]  k
  public void amethod(ref r){5 D: t, R- S7 k$ x: n
  int i=99;0 s) h% v: F& n* U( ?1 w
  multi(r);
. F' N3 f3 g3 b# t1 |7 w* D  system.out.println(i);6 q. J2 @+ F/ U( @) L
  }* s; B9 o  j, b- T
  public void multi(ref r){$ O# i7 }, G: j# \3 ~) w
  r.i = r.i*2;4 x4 L! T; g' w2 t5 A
  }* }7 ]3 ~7 {3 B. S1 \3 {
  }
  y4 f$ D5 S4 o0 c  1) error at compile time
# Q: h) f, l# |( E; O  2) an output of 99
2 x& i2 J5 Q9 A/ o5 a, x3 m  3) an output of 198
! q" g- F" L+ L2 z  4) an error at runtime
. u/ F. M) ?9 z$ Y; W  answer to question 45
% |! w, Q5 `( G% ]5 c  --------------------------------------------------------------------------------
& ?- g8 s1 j( k0 _* {  question 46)
/ R0 |% D! I5 B* @8 C3 y  you need to create a class that will store unique object elements. you do not need to sort these elements but they must be unique.
  m  L. D& _6 v$ N) @3 `  what interface might be most suitable to meet this need?
5 V9 K: d. e' ]5 T/ [  1)set
3 v$ ~8 R, Z, \4 r. f4 Z  2)list
, f5 F0 h7 N' Q0 r, p8 `; L  3)map4 P0 m% f0 V1 ?% J3 G' T* J
  4)vector
6 |$ T5 Q. a8 X+ {! r  answer to question 46
0 ^( k* b+ b7 f' ~. @8 n. X/ J7 M  --------------------------------------------------------------------------------$ z! k7 L) k. c# n5 G+ C
  question 47)/ ~9 Y8 g5 ?' v( p
  which of the following will successfully create an instance of the vector class and add an element?$ L8 V0 o6 k# u
  1) vector v=new vector(99); , k4 y% H$ {# C5 `) W

7 U% r+ Y9 s1 s0 ?7 L5 @  v[1]=99;
回复

使用道具 举报

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

java认证试题:Java认证模拟题及分析(4)

</p>  2) vector v=new vector();+ I9 y. H  F* q; D
  v.addelement(99);
* i! B$ g* k- }5 z! v3 Z0 P$ G  3) vector v=new vector();
1 w+ |6 i' Y" U+ x5 a/ m  G  v.add(99);% R0 s3 n' U( g: w' B
  4 vector v=new vector(100);
- E: J2 J  H  a2 r  v.addelement('99');2 C# h' ]& q- f0 o( G& L1 n
  answer to question 47; g% e& ~% A6 n% K. D: x
  --------------------------------------------------------------------------------- P& I* T& F9 w& @
  question 48)
- f) i  L: a8 M) E. B( d  you have created a simple frame and overridden the paint method as follows
$ {' p' C- Z9 l8 u  public void paint(graphics g){
7 }+ d+ A" N5 V; @- W3 }  g.drawstring('dolly',50,10);
6 {, W3 B3 j7 w, d  }
; ?& _1 h& Y9 U8 y  what will be the result when you attempt to compile and run the program?, w7 [& O" I! l! P9 G& M5 `
  1) the string 'dolly' will be displayed at the centre of the frame
0 w  C1 A8 S9 k4 Y: b6 o" Z% d7 o  2) an error at compilation complaining at the signature of the paint method8 H* P) a0 {% [4 O; @+ [8 L: l
  3) the lower part of the word dolly will be seen at the top of the frame, with the top hidden./ i9 @  p7 [" B
  4) the string 'dolly' will be shown at the bottom of the frame.
& n2 c6 E' @" C( Y* ]  answer to question 48
7 s0 X* B7 i; w. k* k' w  --------------------------------------------------------------------------------$ b4 P8 Y/ S' c( @2 g! _
  question 49)
9 q+ ~8 W" o& j/ y; u  what will be the result when you attempt to compile this program?# q$ K* c4 K/ h2 y3 F
  public class rand{0 Y5 v  M6 j: y) ]% P2 @$ {3 J
  public static void main(string ar[]){ ' c/ u  C/ K, k5 M1 K; b
* i8 I4 P! m! r. W3 Q/ p
  int irand;) J0 a. c: q/ b1 K+ X  x
  irand = math.random();
2 `' R6 O' s0 L# t0 ~  system.out.println(irand);
" p+ `# e* E  H; D1 U  }
4 P0 ^% y5 o3 D  }
6 p6 i/ a. r( h  1) compile time error referring to a cast problem
7 K5 r" K0 v" E& D3 p9 U2 {$ C  2) a random number between 1 and 105 N0 R! x' k' p9 j; r
  3) a random number between 0 and 1) q: w3 S% n. X' ~$ v, Z2 i
  4) a compile time error about random being an unrecognised method; O3 V* R' q' F2 }& h2 z
  answer to question 49
回复 支持 反对

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-5-22 08:44 , Processed in 0.380315 second(s), 23 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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