a我考网

 找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 118|回复: 1

[考试试题] java认证试题:Java认证模拟题及分析(2)

[复制链接]
发表于 2012-8-4 12:33:16 | 显示全部楼层 |阅读模式
  which of the following statements are true?
. h$ n6 j. r' X1 F  1) methods cannot be overriden to be more private
0 `9 y7 U: \6 U+ n9 m+ z$ e  2) static methods cannot be overloaded( D* A( V: j8 J6 D) _# b
  3) private methods cannot be overloaded
5 \* ?9 {: ?8 A4 _4 D  N8 K8 c- v  4) an overloaded method cannot throw exceptions not checked in the base class
( F4 H, X( P8 i3 O7 G8 z' ?  answer to question 16$ x% U3 \4 w1 }4 P- v4 K
  --------------------------------------------------------------------------------
7 E; V! M+ A8 ?" `4 E" e0 @  question 17)) d9 {7 H- m9 a$ I8 Z% R$ J
  what will happen if you attempt to compile and run the following code?# @0 @- z# Q) x+ ^
  class base {}
/ v; C2 ]2 P2 C7 O  class sub extends base {}5 \- Q) @" [+ J6 s( q
  class sub2 extends base {}6 B8 ^6 \0 u! `: J
  public class cex{
3 q! m! D  c- h4 e  public static void main(string argv[]){
1 y' o  [# k& O  base b=new base();
1 U3 K4 K; L( y) f( L  sub s=(sub) b;
. y7 g' Y2 g5 g# j1 W' u# l  }
3 a$ {+ p: A0 K+ D  }
8 e- H$ m% n- w, ?# t$ j7 h  1) compile and run without error- ~6 P8 h3 k4 S9 k* a
  2) compile time exception
# S1 {. w/ P  S3 t" {  3) runtime exception) o( A6 H& q3 O
  answer to question 17  f  Q7 y. q# N' m- F, U' W4 T( i" @
  --------------------------------------------------------------------------------' F) E' m# i) A: e5 i
  question 18)& Z, w9 s$ \& I: y5 F
  which of the following statements are true?
, n; e9 L5 b/ B# _  1) system.out.println( -1 %26gt;%26gt;%26gt; 2);will output a result larger than 10
7 n) Z+ C5 ?2 W5 a  2) system.out.println( -1 %26gt;%26gt;%26gt; 2); will output a positive number ' ?8 D3 M1 P; d9 v+ @; Q
( m$ \* \& `( ~1 V
  3) system.out.println( 2 %26gt;%26gt; 1); will output the number 1
8 G7 a- r" R  ]2 g  4) system.out.println( 1 %26lt;%26lt;%26lt; 2); will output the number 45 C' |% t: Q; a# i' `
  answer to question 18. j7 z! ~' o* R* n/ A: f) l
& b0 c. c1 Q* D) C
  question 19)
回复

使用道具 举报

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

java认证试题:Java认证模拟题及分析(2)

</p>  what will happend when you attempt to compile and run the following code?
- o0 g: j$ I, N) L  public class tux extends thread{
4 @+ }  N0 H$ T3 N* ^' o3 W  static string sname = 'vandeleur';
9 d& I( ]5 H% }% f$ q  public static void main(string argv[]){  S" N9 y0 L) M! q- l: L
  tux t = new tux();2 [+ _: k* ^( W% I0 x) @
  t.piggy(sname);
# l4 \5 Z' N$ [6 Q' Q) ]  system.out.println(sname);9 z* H: N) p# [& ~1 i1 C" t
  }6 b: ^2 R- d+ j. ^
  public void piggy(string sname){
- D8 m  O0 p7 K2 N( }- ^  sname = sname + ' wiggy';- B8 }. V  A& S+ J9 E! [9 T+ G& Q$ d
  start();  z3 ~, p& s& E% @; n4 ~
  }/ `# S' a1 `+ |! Q
  public void run(){& \0 R+ l+ y3 Z; b9 b; b
  for(int i=0;i %26lt; 4; i++){2 d  p! h2 l+ [* U2 U
  sname = sname + ' ' + i;& B% R9 `4 q) W: T& Y1 b
  }
9 Q, T  i% i! M; w- \9 D, O6 E9 @  }
2 d) O5 u2 {: r$ Y( B5 ?' n# u  }
6 x3 h4 s8 \, B# Z  1) compile time error! {1 T$ P/ Y0 ^! I' @1 Z0 Q
  2) compilation and output of 'vandeleur wiggy', D5 i  W. ?( O; p4 ?( A
  3) compilation and output of 'vandeleur wiggy 0 1 2 3'
5 q4 i6 k: T! O0 G  4) compilation and probably output of 'vandeleur' but possible output of 'vandeleur 0 1 2 3'' p# [( T3 ^& ?3 _, _. ~8 n
  answer to question 19# ]* _7 P. e& _9 e7 O0 m2 J) f9 n
  --------------------------------------------------------------------------------0 \7 N6 B- a4 J; X
  question 20)2 o8 F2 H& Z# w, m& G( a( @# C2 |' m& z
  what will be displayed when you attempt to compile and run the following code
$ ~' e2 T" C) {2 i  A  //code start
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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