a我考网

 找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 105|回复: 1

[考试试题] JAVA认证历年真题:310-025精选题(27)

[复制链接]
发表于 2012-8-4 12:33:16 | 显示全部楼层 |阅读模式
91. Which number for the argument must you us e for the code to print cat?! i- S6 b6 t% _+ ^
With the command:. x7 I% S8 X$ b# W7 O
java Prog cat dog mouse, I/ X: a( x5 M. H
public class Prog {: ]0 o, @" X! S, {; e
public static void main(String args[]) {
' `- Q2 a) V4 w9 X) U: L3 u& R' vSystem.out.println(args[?]) ;5 l* y$ I3 |/ c9 G: W) s# H" p) g
}' {8 I- \1 R. Q7 w
}* B9 g. f9 f" t9 u% `
A. 09 I) g9 B/ P( b- F' h
B. 1
" Z7 K5 u: m3 y; ~6 h+ M; v: a3 UC. 2
/ |- A3 X$ w6 D- {1 ]- XD. 3( b- x4 k& R0 q
E. none of these0 E# h8 |, s" z8 @7 M2 ?
A.
% A& f  e& T. d& s92. You have the following code:8 f  j) I. u( Y5 A% [& j$ f
.......5 e$ i- ?) U: ^' q  Z
String s;. U* {5 Q$ m3 T- J% {4 K6 N
s = "Hello";
1 v9 G1 g* u5 g6 {( T! L/ ht = " " + "my";
# S! p1 Q$ h2 T3 t5 A9 t$ K6 as.append(t);5 _( e; p. n) t: N
s.toLowerCase();
9 d7 S# A' n2 w1 Hs+= " friend";
3 y9 q$ H4 ^) j1 `" F/ XSystem.out.println(s);2 {, W$ R$ V( [7 S
What will be printed?
; ~9 U3 x5 a" s* JAnswer:5 @% P) k6 R  N7 @3 l
hello my friend
回复

使用道具 举报

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

JAVA认证历年真题:310-025精选题(27)

93. What will happen when you attempt to compile and run this code?
1 u! T+ N* @' o! s5 b" d1 dpublic class MySwitch{1 K, f1 v1 b0 |& s) z( Y
public static void main(String argv[]) {2 S, U$ r3 v  ?. L$ \5 P
MySwitch ms = new MySwitch(;% R% N# s1 J+ ~' u0 {- r
ms.amethod();3 x# _; O1 c, B. }  s. J# V
}
. n( @- E4 N1 E* F& Z$ W6 ^public void amethod() {
# p+ H7 L1 b0 p/ xchar k=10;
! H5 F3 O9 h, g: I- l% G7 c- q3 ^switch(k){
# r$ i# z' [2 O& i2 Rdefault:6 ~$ ~5 M6 d1 f4 o
System.out.println("This is the default output");: k, c! P% Z& ~. R+ f8 S; a
break;/ B( q) G* W7 W7 O  m! q
case 10:% \& }2 z* w2 G6 Z& i$ f
System.out.println("ten");
& f; b8 F* O% Z" l0 Dbreak;
9 x' l5 ^- r4 Z( Ncase 20:
0 s; N  i! E0 R; k% aSystem.out.println("twenty");8 T8 @9 m9 V; O& d3 |7 L
break;1 K% m' c9 o! X
}
  O/ y& A* P! d1 ~5 C}
2 A1 @; W( V, \9 G}  v5 ]0 U, j. y4 b3 k
A. None of these options
! {2 ^. ]+ }" j0 h1 LB. Compile time error target of switch must be an integral type- `4 y" T, i6 C4 D% \9 ]6 m" _
C. Compile and run with output "This is the default output"
2 b/ d/ b) I. V9 c( J0 t& WD. Compile and run with output "ten"# n1 G0 T/ a2 W/ W" O9 X3 t
D.+ D0 O* A; f+ N) \9 v
94. What will happen when you attempt to compile and run the following code?) V* K! s9 e9 L8 g9 p
public class MySwitch{8 D$ F; h/ i3 Q1 [# P
public static void main(String argv[]) {
8 K. G) j) H8 z0 M$ `+ _MySwitch ms = new MySwitch();$ u- _9 F1 F7 @0 {$ j. G; g/ e
ms.amethod();
# z$ g9 [5 s- U}. T! ~+ n7 e1 s& l6 m7 s" e
public void amethod() {. o6 j0 D2 q4 E0 S
int k=10;3 ]# ~+ |: K+ Z5 Y
switch (k){' H- u1 `0 h! T& m  D. k& v7 `
default: //Put the default at the bottom, not here
* c" N! G; \' ~2 q$ y" sSystem.out.println("This is the default output");* C- d9 Z, V/ z8 k" a7 Q! U! t
break;; D% m* Y* w3 F6 X& A. y
case 10:5 f3 @% s# z0 ?" g( v8 c) b
System.out.println("ten");
/ p/ }7 {$ r- B/ D7 F0 v& ocase 20:/ i. s3 r( d7 t* r
System.out.println("twenty");. ]* O% H4 Z# r2 K7 K6 U
break;6 i/ p3 ^" K1 j' o+ A
}' s) h) K, ^4 V
}
  ]0 }% r$ Q7 k9 }. }" C) A: Z}
6 M, H' L. I9 p8 _" r# bA. None of these options
$ c; n+ ]  B. {B. Compile time error target of switch must be an integral type
. O# E6 ^9 v% a# y9 H5 xC. Compile and run with output "This is the default output; b- H* j9 [. p; x7 ]+ z
D. Compile and run with output "ten"& B3 k5 q. n5 U+ F( \' \
A.
回复 支持 反对

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-6-2 17:13 , Processed in 0.182335 second(s), 23 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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