a我考网

 找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 92|回复: 1

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

[复制链接]
发表于 2012-8-4 12:33:16 | 显示全部楼层 |阅读模式
  Q4.You are writing a set of classes related to cooking and have created your own exception hierarchy derived from java.lang.Exception as follows Exception
+ x3 s" V6 j1 j& x4 W9 n" s  +-- BadTasteException  A7 t, C- n/ ?: E$ |, s% G9 [
  +-- BitterException, W2 w& M& S  q. |" A
  +-- SourException
6 e+ Y% n6 V4 ^: n+ P  Your base class, “BaseCook” has a method declared as follows int rateFlavor(Ingredient[] list) throws BadTasteException A class, “TexMexCook”, derived from BaseCook has a method which overrides BaseCook.rateFlavor(). Which of the following are legal declarations of the overriding method?
) q& |1 L; t8 u  K8 O; h  a. int rateFlavor(Ingredient[] list) throws BadTasteException; }$ k) V4 I3 f/ f  O) W' z
  b. int rateFlavor(Ingredient[] list) throws Exception7 U  ]0 h. X" m
  c. int rateFlavor(Ingredient[] list) throws BitterException, w: J5 J# {8 p4 a
  d. int rateFlavor(Ingredient[] list)
7 o  Q- Q' }# u, P  Q5.You are working on an aquarium simulation class named Aquarius. You already have a method which adds a Fish object to the aquarium and returns the remaining fish capacity. This method has the following declaration." t8 }, ?6 _* X# D/ t
  public int addFish( Fish f )+ ]+ f# u0 t1 m2 g% j$ q
  Now you want to provide for adding a whole shoal of fish at once. The proposed method declaration is protected boolean addFish( Fish[] f ) The idea being that it will return true if there is more room in the tank or false if the tank now too full. Which of the following statements about this proposal are true?# O) [. j- [2 ~/ w$ e
  a. This technique is called overloading.
3 N, D0 l5 |. s1 Y$ c! I  b. This technique is called overriding.5 H( W1 h% b+ d# J0 ^( S. S- N+ s
  c. The compiler will reject the new method because the return type is different.
: S0 l% t1 U8 _& ]5 l" V8 ^' R1 o: }
# X8 P$ T+ q5 |9 b# p  d. The compiler will reject the new method because the access modifier is different.
回复

使用道具 举报

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

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

</p>  Q6.You have created a TimeOut class as an extension of Thread, the purpose being to print a “Time's Up” message if the Thread is not interrupted within 10 seconds of being started.( F; x+ I; m+ V
  Here is the run method which you have coded.. W! T! k0 b7 ~
  1. public void run(){+ Z8 @5 N3 t! z  n
  2. System.out.println(“Start!”);
" x  s" R; e& }9 l/ s2 u  3. try {
$ Y5 v8 ?% L' K& F9 W. a  4. Thread.sleep(10000 );( B+ o. y" G5 N& N" N) w7 S* a7 Q2 m
  5. System.out.println(“Time's Up!”);' j( S. G3 s$ j0 Y& w" E
  6. } catch(InterruptedException e) {& m# p# `7 F& V. H4 P
  7. System.out.println(“Interrupted!”);
# s' ?0 E, M+ t1 o0 M0 ^  8. }1 J+ ]4 b  y, a8 q. H  W- ]5 ]8 B
  9. }
' H: @" Z' Z* W0 n. B& s$ {. y  Given that a program creates and starts a TimeOut object, which of the following statements is true?" q) r/ E" y4 {; y% ~3 [$ n8 d
  a. Exactly 10 seconds after the start method is called, “Time's Up!” will be printed.9 T2 ~. x3 V% |
  b. Exactly 10 seconds after “Start!” is printed, “Time's Up!” will be printed., g. n" v" s* Y1 a4 W0 }& k
  c. The delay between “Start!” being printed and “Time's Up!” will be 10 seconds plus or minus one tick of the system clock.
1 p" w* m9 L/ s4 g+ w4 b( T$ b  d. If “Time's Up!” is printed you can be sure at least 10 seconds have elapsed since “Start!” was printed.& Z! m( ]3 f) W( W. [
  4. acd( Y/ L' u3 l, @. d/ P# l( c9 [
  5. a' [( g8 }% m3 q  _7 Q
  6. d
回复 支持 反对

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-6-29 19:20 , Processed in 0.219487 second(s), 23 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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