a我考网

 找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 118|回复: 1

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

[复制链接]
发表于 2012-8-4 12:33:16 | 显示全部楼层 |阅读模式
  Q16.What will happen when we try to compile the following code.: {. m3 e, c+ S1 O
  1. public void WhichArray( Object x ) {
, k6 L5 M) L( S$ S& H) u  2. if( x instanceof int[] ) {' G' b3 b; [8 G3 r
  3. int[] n = (int[]) x ;
* }* q# E3 B2 R  4. for( int i = 0 ; i < n.length ; i++ ){
6 c$ d; X* |3 B' o1 {+ {; ^  5. System.out.println(“integers = “ + n );
8 \6 r! M$ }- Q  6. }/ e$ E  z' D6 ^: I& m0 K
  7. }
8 }0 R, w; {. U, X  8. if( x instanceof String[] ) {3 y6 o: |: u7 |  J! ^8 Z* F8 R# W
  9. System.out.println(“Array of
4 g$ {) c! P; L2 k  Strings”);
. e0 A4 H% `2 E+ g  10. }! c/ E8 e6 {& m0 ^/ W
  11. }4 [- g9 @# d" {/ V) g( `
  a. The compiler objects to line 2 comparing an Object with an array.
  I5 u/ G5 |1 x3 y  b. The compiler objects to line 3 casting an Object to an array of int primitives.8 D# {& G% v1 m1 U
  c. The compiler objects to line 7 comparing an Object to an array of Objects.0 @! O- {. v2 `' ~* v
  d. It compiles without error.
( \/ p9 I6 ~. K, @( i% d- V
7 z6 H$ }& Y. C  Q17.Consider the following class
回复

使用道具 举报

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

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

</p>  1. class Tester {: Z7 j, ~( p9 K1 W3 g
  2. void test (int i) { System.out.println (“int version”); }5 i2 X$ o& ^# g3 k* ]' w1 Q
  3. void test (String s) { System.out.println (“String version”); }* D4 u) V" n- g$ `# u! b6 g. O
  4.
. i0 ?- Z5 d3 Z+ z4 b  5. public static void main (String args[]) {6 N( Z2 L/ S. ?1 R! s" k. e
  6. Tester c = new Tester ();
- ?2 N- h% D  ~' |3 D/ `  7. char ch = 'p';
% I/ w/ S0 i/ J: ^8 a" Q  8. c.test (ch);
1 T9 o3 e/ p5 S" P  9. }
/ D0 |. V5 N. W& F6 W  10. }
8 C0 R, Z! y8 l5 s  Which of the following statements below is true?(Choose one.)6 H1 U& K3 ~7 W- O
  a. Line 3 will not compile, because void methods cannot be overridden.6 A, ?$ b5 }  U. M
  b. Line 8 will not compile, because there is no conversion of test() that takes a char argument.
& n) r2 ^/ m+ `+ E( E  g! U  c. The code will compile and produce the follwing output “int version”
) t- l  {" h; G& X  d. The code will compile and produce the follwing output “String version”
1 R' ^. ]' h' O) F  Q18.You are creating a ToolBase class which will be extended by other programmers. The ToolBase class contains a single abstract method, createTool. Which of the following statements are true?
' ]" G) L9 O# L& ?  a. The ToolBase class must be declared abstract." d/ @/ s6 D- @. N3 Q4 A  A
  b. Classes extending ToolBase must not be declared abstract.
& L8 [5 s5 \7 r& d( y% i& m, m  c. The ToolBase class must not be declared final.; F" N( c7 ~! ]( j) ^2 u# Y$ }( _3 n
  d. The following variable declaration is illegal in any context “ToolBase myTB;”
& C- H* c8 }5 J) B/ w  16. d* M# d0 Q& w5 X
  17. c1 [* i: J' R* ?/ m- ~
  18. ac
回复 支持 反对

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-5-18 02:17 , Processed in 0.160518 second(s), 23 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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