a我考网

 找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 101|回复: 1

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

[复制链接]
发表于 2012-8-4 12:33:16 | 显示全部楼层 |阅读模式
question 1)
+ w, ?# b  c# Z! q, ?which of the following lines will compile without warning or error.
- s; F2 X1 W5 s& m! \- v1) float f=1.3;   l+ K! r3 j  ]" v7 S- q" X
2) char c='a';
3 b/ f: z/ Z9 }* Q3) byte b=257;
  f; g* \; p1 ~# m. H4) boolean b=null;
2 \2 \' C' H. B' o! S+ _3 D5) int i=10; 1 l8 z% C; g% s1 Y! K1 ^& K5 K* d
answer to question 1
/ a3 \; J7 F  Q4 ^3 d% m0 ]$ P--------------------------------------------------------------------------------
3 H. W% i+ s+ w" kquestion 2) + ^8 y. m# b8 c1 P8 M
what will happen if you try to compile and run the following code
- E4 t  b9 P" Gpublic class myclass {
: L, x: i8 E# J% i4 e6 [public static void main(string arguments[]) {
( B1 a0 |' z" e/ j8 jamethod(arguments);
6 T, J, J- m1 [( l" P  j5 x} 3 @" k+ {5 U4 Z* c
public void amethod(string[] arguments) {
: J3 Y2 ]& W+ U, f) L. c3 X  @: i9 Esystem.out.println(arguments); 9 Z+ ^: ]! P  x7 o$ ~
system.out.println(arguments[1]); * ~6 s4 ?9 A- ~" T7 ^0 _3 |' L; Z8 j
}
: z5 J6 L( `. S9 F; r) ?} - Y9 f' [/ K1 k' ~# u" c0 R
1) error can%26acute;t make static reference to void amethod. # B/ W$ s/ Q  }1 ~
2) error method main not correct 4 I* O  p' I5 ~4 H% X
3) error array must include parameter ' I3 l' A5 b' t& p! J0 b
4) amethod must be declared with string
6 |9 z4 P9 x6 @" I/ wanswer to question 2 % l6 |: {1 r& z& P& H; d/ w$ x
--------------------------------------------------------------------------------
4 Q  j, Q& P1 `/ n0 c3 ]1 z/ E  x6 oquestion 3) & H3 ]0 W0 a1 G* L- E( V
which of the following will compile without error
1 T, S0 k; P$ }4 g( O1) & o) D1 ^7 S1 T  m
import java.awt.*; $ ?; j9 ~) [; z/ \
package mypackage; ! {! X. O7 e$ D
class myclass {} ' ^' E* y9 s# U$ a: i
2) $ R1 ~( z3 _- s3 Y/ F& X
package mypackage; 7 ~8 ]+ t# S* }. ]  S0 U+ r. i2 {2 I
import java.awt.*;
# n+ U5 p$ s  V* z6 A0 V5 C6 _class myclass{}
  s# @* V% t$ t8 X3) , u- s! e( t6 K
/*this is a comment */
( F' c. P0 p. L, b$ E- Dpackage mypackage; 1 M& J2 G  Y4 F4 e9 T% [+ y. e
import java.awt.*;
" z; d: Z: Q1 Aclass myclass{}
! [6 R% D8 h7 l3 ^- Sanswer to question 3
) R. f- x" o. h, m. ]7 C" D5 [5 I1 {* Y% U4 a$ `, M8 D
--------------------------------------------------------------------------------
回复

使用道具 举报

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

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

question 4)
3 @% _4 X* o. G. Ma byte can be of what size 7 N- x! Y7 Z" m% C% s
1) -128 to 127 $ `! ]' o- s* X# t' ~1 c
2) (-2 power 8 )-1 to 2 power 8 6 Q" _/ b# M( @8 U+ r
3) -255 to 256
: S$ K% m$ d6 Z  X* G  C4)depends on the particular implementation of the java virtual machine ( j0 q/ _6 J! u4 r# p) v" U, H  ^4 ^
answer to question 4 </p>--------------------------------------------------------------------------------
2 h/ }% I' ~  G: g9 L8 k/ g8 uquestion 5) 4 G* V) R1 O( r% ]3 _
what will be printed out if this code is run with the following command line? ; L0 {4 ~# N* p4 C
java myprog good morning 7 Y! n8 M. K9 }( o/ i! E
public class myprog{ : w; E( A" Z0 A8 O
public static void main(string argv[])
' t5 ]4 [9 c" Q. O1 `# E) s( Q/ v{
  S$ m+ N' D- g, @5 X: o, Dsystem.out.println(argv[2]) # n! i8 [: \  r, S6 a$ E
} " b! P/ P% b. }6 ~. C
}
8 `0 i3 a4 {( A1) myprog # X6 {) F1 m( E
2) good ' e0 R$ a- j, `/ \
3) morning ) J* {/ R5 R8 u. ?
4) exception raised: 'java.lang.arrayindexoutofboundsexception: 2' " F- E. I/ }# e( f3 s) b; X3 d% j
answer to question 5 8 X) q6 c$ @; \( e2 k
-------------------------------------------------------------------------------- & B8 Y/ m5 ~8 e' B( f0 i
question 6) % g3 F- S# ~" x5 C, |
which of the following are keywords or reserved words in java?
4 \$ V8 {( r0 b6 U9 x5 I, f2 i- ]0 G7 ?1) if
; ?; H! x5 k! L; P/ B, _2) then ( X# n% p$ h! \9 T
3) goto
! z% E) |  V2 t4) while
回复 支持 反对

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-6-10 16:56 , Processed in 0.216963 second(s), 24 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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