a我考网

 找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 198|回复: 1

[考试试题] 2011年JAVA认证模拟题第二阶段(3)

[复制链接]
发表于 2012-8-4 12:33:16 | 显示全部楼层 |阅读模式
  Q7.What is the output of the following program?% u3 X! X& Q9 r3 P" ~/ r
  1. class Base {# i* [7 s: x, s( c* n
  2. int x=3;
1 P2 t* H, O8 ^7 ?) x  3. public Base() {}
! {. o' B: r4 o, C" p! f$ i( {: x  4. public void show() {
0 n6 q& h) K" s' D  5. System.out.print(“ The value is “ + x);' J( U+ {; g0 d5 n) I
  6. }
  k5 ^$ }1 C$ ?3 ?! c+ S* O' j  7. }* X/ _7 x( e; l6 N& I. I% H) x
  8. class Derived extends Base {
1 G/ \: a% W' E1 t* C. i  9. int x=2;
1 P: Y6 n+ w0 l5 ^; u& ?  m4 K; ]  10. public Derived() {}$ _0 n! Z. T9 G$ ]; g1 m  q
  11. public void show() {
$ i! Z! v: g, ~- ~! }  12. System.out.print(“ The value is “ + x);
8 M, @# F8 f- G# H$ y, ?  13. }
. z: J+ x, D; e  14. }
8 ^$ P4 i' m5 K4 ]: M* i/ z) X  15. public class Test {
4 b' A( l3 q/ h+ J  16. public static void main(String args[]) {
* f5 e2 @( W: T" {. S9 R( }' G  e  17. Base b = new Derived();
- c6 z: g+ g. D% u0 Z  18. b.show();  e! Y1 s; a! z7 F
  19. System.out.println(“The value is “ +b.x);
; E( K! p+ r6 c& M% ]$ m; }  20. }
$ r  }) D! `3 ]; Q
% s/ ]& I5 s! H1 G8 {  21. } // end of class Test
# S( r8 g7 g' [1 n  a. The value is 3 The value is 2- M) ^$ I8 J3 ]0 H$ s+ [
  b. The value is 2 The value is 3
4 q( C/ e4 o4 m' ^  j8 _  c. The value is 3 The value is 32 t; Y8 l1 [. d$ M8 @  P- L
  d.The value is 2 The value is 2% p" J0 Y9 H5 S  o; o
  Q8.What is the output of the following code?
3 q  C- \! Z9 X# {: k9 z  1. public class Note {
; f/ K* C6 G8 N6 q  2. public static void main(String args[]) {
; s5 T# @' O. @6 `  C2 e; s5 N% L  3. String name[] = {”Killer”,”Miller”};0 F" o" t- h! w9 \: Z
  4. String name0 = “Killer”;
. F( r1 U0 x* o0 a  5. String name1 = “Miller”;( p! f1 e4 @, ]3 H0 u
  6. swap(name0,name1);; X: Y$ s7 Y4 L
  7. System.out.println(name0 + “,” + name1);' q  n9 O2 j* y/ Z2 @
  8. swap(name);' o; T. I, }# p( u
  9. System.out.println(name[0] + “,” + name[1]);
; T) a3 @: n( O0 q  10. }3 H! ]1 p0 |* {" l) X5 N( x2 J$ F
  11. public static void swap(String name[]) {& e2 e6 T3 Y5 B
  12. String temp;+ d6 i8 e8 \' R: d
  13. temp=name[0];
. O# V" b8 p3 z  14. name[0]=name[1];
; C  I6 ^  I! P6 Y
1 o4 z  W! ~: r/ @5 ~# a  J  15. name[1]=temp;
回复

使用道具 举报

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

2011年JAVA认证模拟题第二阶段(3)

</p>  16. }
) G) ~# R9 ~6 [5 _8 U7 P8 K  17. public static void swap(String name0,String name1) {
3 c# m) g  y7 I7 C5 K  T' M. S1 P  18. String temp;
! k* N9 j' P2 t  19. temp=name0;
5 v4 b+ D4 a! O) G6 H  20. name0=name1;
2 i4 a, ?( r. J3 L  ~: W3 Y. L0 x  21. name1=temp;1 i) U3 ?  ~9 l
  22. }
. c! n% }0 A7 E  23. } // end of Class Note1 w6 A. K- N2 A7 W
  a. Killer,Miller followed by Killer,Miller
- G5 Y% N) J& X2 X/ X  b. Miller,Killer followed by Killer,Miller
) r9 [1 L7 t: n- X, S  c. Killer,Miller followed by Miller,Killer# J# |% z% Z2 e1 n
  d. Miller,Killer followed by Miller,Killer
" i0 T! P# [. j% h% [; v  Q9.What is the output of the following program?* u7 B. w) A2 W3 y' ?
  1. public class Q11 {
* d$ N7 H! g* B/ i6 y" [8 _  2. static String str1 = “main method with String[] args”;
! x( P$ g5 N6 j5 H( }  3. s tatic String str2 = “main method with int[] args”;/ ^2 t/ s7 `+ L: z
  5. public static void main(String[] args) {
( G0 d* X  Z* ^" ^7 ~6 N# t  6. System.out.println(str1);
8 u) V$ L3 E$ `: @+ m  7. }2 Y3 q6 g% R- h: q+ _9 ~4 u
  10. public static void main(int[] args) {) f" b, @0 \; `' e3 s/ G
  11. System.out.println(str2);
! e' g+ l6 P9 l$ o. Y0 c  12. }4 I! d5 Q1 q+ J7 M* Y
  13. }
! ?3 u. Q7 f3 K- P7 _  i! `  a. Duplicate method main(), compilation error at line 5.6 P% M! y7 @; R! x
  b. Duplicate method main(), compilation error at line 10.( h9 v% P: [9 i% n
  c. Prints “main method with String[] args”.! h7 `+ r- i: H* D8 F( C+ B6 @
  d. Prints “main method with int[] args”.
5 x( j' j7 H* }& K  G  g+ A1 l4 A  7. b' K9 s5 C7 w; H% s
  8. c
3 f* Y. r7 v; x  9. c
回复 支持 反对

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-5-21 16:04 , Processed in 0.165908 second(s), 23 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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