a我考网

 找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 139|回复: 1

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

[复制链接]
发表于 2012-8-4 12:33:16 | 显示全部楼层 |阅读模式
  Q64.Given the following code for the Demo class- T, I( ]$ ]* @1 L( X2 y( H, O% R
  1. public class Demo {1 W, i0 @& R2 [2 G7 k/ ]; p* |
  2. private String [] userNames;
' V# ~- H4 l" N7 q9 f  3. public Demo() {
& y3 J4 B5 l* @' o! _8 g2 f6 P  4. userNames = new String[10];
% N$ k/ o2 X# {9 ~) B; Z; `: c  5. }
4 q; I- \$ ^0 B: f* c8 X  6. public void showName(int n) {
' O4 ?: A7 l& E3 K1 o( c  7. System.out.println(“Name is “ + userNames[n]);9 E; m/ O! u5 t$ r7 r5 z  T" ^
  8. }% ^% O9 J  d3 X; {3 A
  9.) D3 r8 i9 e2 Y+ `7 C4 x
  10. public String getName(int n) {
# u/ u- Y, E, J  11. return(userNames[n]);
: J1 X9 j( c. Z- ~9 Y" Z# t* L  12. }3 G1 b; l8 p( N9 ?8 q$ ^% J
  13. }
  b6 `. V- L( H) Z0 R  What would be the result of calling the showName method with a parameter of 2 immediately after creating an instance of Demo7 S% L' F$ c$ f( P/ n
  a. Standard output would show “Name is null”.
9 @9 v% Z/ V. l! h. i  b. A NullPointerException would be thrown, halting the program." c7 s2 F8 o- j* y/ c
  c. An ArrayIndexOutOfBoundsException would be thrown halting the program.
& P  L7 }' A. t1 f" i. ?  d. Standard output would show “Name is”.# v5 F% ^+ }' S7 h( e1 L
  Q65.What will be the result of attempting to compile and run the following class?
! z4 ]+ q3 v9 n" N" B( t" v# I  1. public class Integers {
  f4 F) L! z9 R6 h6 Q  2. public static void main(String args[]# P/ [) r# }% t& ]
         ) { ) z3 N% N* U1 T9 z9 C
  I" I% b! t' w, N. e! F0 @! f
  3. System.out.printl(0x10 + 10 + 010);) W& P* t" v! Q. k# e* S
# n, N2 ]/ O/ e8 Y
  4. }
回复

使用道具 举报

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

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

</p>  5. }
/ O( E9 ~- V) a. m# b" h  Select the one right answer.
; `2 ^% b3 d; l  a. The code won't compile. The compiler will complain about the expression 0x10 + 10 + 010# V, N, Z- m  a1 g4 [, l- W
  b. When run, the program will print “28”
9 r2 G. t: h, E* b0 c, q& D7 n( I  c. When run, the program will print “34”
+ s+ M7 V4 h- R8 _2 `  d. When run, the program will print “36”
+ q- L/ h' G7 }; x# j  Q66.How will the following program lay out its buttons?  M9 \. m* h% Q# h/ `
  1. import java.awt.*;( V$ y& c4 y6 @" _" |4 L# ^
  2. public class MyClass {
2 D/ }: u1 I- M. K5 ~  3. public static void main(String args[]) {( K8 K: m" C7 S
  4. String labels[] = {”A”,”B”,”C”,”D”,”E”,”F”};
. U/ M9 e# \& {# V# ]  w" [/ D! n  5. Window grid = new Frame();. v; p7 X& Z5 j6 ~
  6. grid.setLayout(new GridLayout(0,1,2,3));
0 A3 i" e& ^! L; x$ O9 Q1 `4 H) g4 e  7. for(int i=0;i$ A0 n2 C# U+ b% |" ?3 {
  8. grid.add(new Button(labels));
7 W4 N, t; {2 N9 I  9. }0 z" F% s5 i: X' J, \9 ^
  10. grid.pack();# [+ B! N4 s# ^: }! Y) W/ I+ ]8 a
  11. grid.setVisible(true);1 _4 x: b% a+ O4 y: a
  12. }% W/ @; L# g- g' x0 O3 A# ~* E1 L
  Select the one right answer
1 e  I# r& T/ `+ v, {9 W  a. The program will not show any buttons at all.
  F1 [' ?; f$ W0 L  b. It will place all buttons in one row - A B C D E F.
$ ]% n) {2 b5 n" h/ L( p6 N1 N  c. It will place all buttons in one column, i.e., each button in a separate row - A B C D E and F.
9 B* V, n# l& Y& K- ~
' T  b. R' x/ k3 x* F! n6 X" j  d. It will place pairs of buttons in three separate row A B, C D and E F./ s5 I. O/ N) _0 M: ]& y* ?8 y
  64. a& t* B( t" J# Q7 @, e8 T9 I+ l2 V
  65. c0 J( v6 w/ ]- `1 v5 ^7 {
  66. c
回复 支持 反对

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-5-22 07:01 , Processed in 0.241091 second(s), 23 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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