【求助】我想考java的認證,請問幾個java的題目

顯示結果從第 1 筆 到 4 筆,共計 4 筆
  1. #1
    wim
    wim 目前未上線
    會員
    註冊日期
    2003-09-15
    討論區文章
    29

    【求助】我想考java的認證,請問幾個java的題目

    No.41
    11. Float f = new Float("12");
    12. switch (f) {
    13. case 12: System.out.println("Twelve");
    14. case 0: System.out.println("Zero");
    15. default: System.out.println("Default");
    16. }
    請問結果是什麼??
    A. Zero
    B. Twelve
    C. Default
    D. Twelve
    Zero
    Default
    E. Compilation fails.

    --------------------------------------------------------------------------------------------------------------------------------------------------------

    No.47
    下面那個敘述是正確的
    A. A try statement must have at least one corresponding catch block.
    B. Multiple catch statements can catch the same class of exception more than once.
    C. An Error that might be thrown in a method must be declared as thrown by that method, or be handled within that method.
    D. Except in case of VM shutdown, if a try block starts to execute, a corresponding finally block will always start to execute.
    E. Except in case of VM shutdown, if a try block starts to execute, a corresponding finally block must always run to completion.

    --------------------------------------------------------------------------------------------------------------------------------------------------------

    No.52
    Given:
    1. class Super {
    2. public int getLenght() { return 4; }
    3. }
    4.
    5. public class Sub extends Super {
    6. public long getLenght() { return 5; }
    7.
    8. public static void main(String[] args) {
    9. Super sooper = new Super();
    10. Sub sub = new Sub();
    11. System.out.println(
    12. sooper.getLenght() + " " + sub.getLenght() );
    13. }
    14. }
    What is the output?
    A. 4,4
    B. 4,5
    C. 5,4
    D. 5,5
    E. Compilation fails.

    --------------------------------------------------------------------------------------------------------------------------------------------------------

    No.59
    Given:
    1. public class OuterClass {
    2. private double d1 = 1.0;
    3. // insert code here
    4. }
    Which two are valid if inserted at line 3? (Choose two)
    A. static class InnerOne {
    public double methoda() { return d1; }
    }
    B. static class InnerOne {
    static double methoda() { return d1; }
    }
    C. private class InnerOne {
    public double methoda() { return d1; }
    }
    D. protected class InnerOne {
    static double methoda() { return d1; }
    }
    E. public abstract class InnerOne {
    public abstract double methoda();
    }

    --------------------------------------------------------------------------------------------------------------------------------------------------------

    No.76
    Given:
    1. class Bar { }
    1. class Test {
    2. Bar doBar() {
    3. Bar b = new Bar();
    4. return b;
    5. }
    6. public static void main (String args[]) {
    7. Test t = new Test();
    8. Bar newBar = t.doBar();
    9. System.out.println("newBar");
    10. newBar = new Bar();
    11. System.out.println("finishing");
    12. }
    13. }
    At what point is the Bar object, created on line 3, eligible for garbage collection?
    A. After line 8.
    B. After line 10.
    C. After line 4, when doBar() completes.
    D. After line 11, when main() completes.

    --------------------------------------------------------------------------------------------------------------------------------------------------------

    No.88
    Given:
    1. public class Exception Test {
    2. class TestException extends Exception {}
    3. public void runTest() throws TestException {}
    4. public void test() /* Point X */ {
    5. runTest();
    6. }
    7. }
    At Point X on line 4, which code is necessary to make the code compile?
    A. No code is necessary.
    B. throws Exception
    C. catch ( Exception e )
    D. throws RuntimeException
    E. catch ( TestException e)

    --------------------------------------------------------------------------------------------------------------------------------------------------------

    No.89
    Given:
    11. int i = 0;
    12. while (true) {
    13. if(i==4) {
    14. break;
    15. }
    16. ++i;
    17. }
    18. System.out.println("i="+i);
    What is the result?
    A. i = 0
    B. i = 3
    C. i = 4
    D. i = 5
    E. Compilation fails.

    --------------------------------------------------------------------------------------------------------------------------------------------------------

    No.98
    Given:
    1. public class Alpha{
    2. public static void main( string[] args ){
    3. if ( args.length == 2 ) {
    4. if ( args.[0].equalsIgnoreCase("-b") )
    5. System.out.println( new Boolean( args[1] ));
    6. }
    7. }
    8. }
    And the code is invoked by using the command:
    java Alpha -b TRUE
    What is the result?
    A. true
    B. null
    C. false
    D. Compilation fails.
    E. The code runs with no output.
    F. An exception is thrown at runtime.

    --------------------------------------------------------------------------------------------------------------------------------------------------------

    No.102
    Given:
    11. public static void main( String[] args ) {
    12. Integer a = new Integer(10);
    13. Integer b = new Integer(10);
    14. Integer c = a;
    15. int d = 10;
    16. double e = 10.0;
    17. }
    Which three evaluate to true? (Choose three)
    A. (a == c)
    B. (d == e)
    C. (b == d)
    D. (a == b)
    E. (b == c)
    F. (d == 10.0)

    --------------------------------------------------------------------------------------------------------------------------------------------------------

    No.103
    Given:
    11. String a = null;
    12. a.concat("abc");
    13. a.concat("def");
    14. System.out.println(a);
    What is the result?
    A. abc
    B. null
    C. abcdef
    D. Compilation fails.
    E. The code runs with no output.
    F. An exception is thrown at runtime.

    --------------------------------------------------------------------------------------------------------------------------------------------------------

    No.104
    Given that b and c refer to instances of wrapper classes, which two statements are true? (Choose two)
    A. b.equals(b) returns true.
    B. b.equals(c) returns the same result as b == c.
    C. b.eqials(c) can return false even if c.equals(b) returns true.
    D. b.equals(c) throws an exception if b and c are different wrapper types.
    E. b.equals(c) returns false if the type of wrapper objects being compared are different.

    --------------------------------------------------------------------------------------------------------------------------------------------------------

    No.105
    Given:
    1. public class Test {
    2. public static void main(String [] args) {
    3. System.out.println(args.length > 4 &&
    4. args[4].equals("-d"));
    5. }
    6. }
    f the program is invoked using the command line:
    java Test One Two Three -d
    What is the result?
    A. true
    B. false
    C. Compilation fails.
    D. An exception is thrown at runtime.

    --------------------------------------------------------------------------------------------------------------------------------------------------------

    No.106
    Given:
    11. try {
    12. if ((new Object))(.equals((new Object()))) {
    13. System.out.println("equal");
    14. )else{
    15. System.out.println("not equal");
    16. }
    17. }catch (Exception e) {
    18. System.out.println("exception");
    19. }
    What is the result?
    A. equal
    B. not equal
    C. exception
    D. Compilation fails.

    --------------------------------------------------------------------------------------------------------------------------------------------------------

    No.117
    Given:
    1. public class X implements Runnable {
    2. private int x;
    3. private int y;
    4.
    5. public static void main(String [] args) {
    6. X that = new X();
    7. (new Thread( that )).start();
    8. (new Thread( that )).start();
    9. }
    10.
    11. public void run() {
    12. for (; {
    13. synchronized (this) {
    14. x++;
    15. y++;
    16. }
    17. System.out.println(Thread.currentThread().getName() +
    18. "x = " + x + ", y = " +
    y);
    19. }
    20. }
    21. }
    What is the result?
    A. Compilation fails because of errors at lines 7 and 8.
    B. The program prints pairs of values for x and y that might not always be the same on the same line ( for example, ※x = 2, y = 1§).
    C. The program prints pairs of values for x and y that are always the same on the same line (for example, ※x = 1, y = 1§). In addition, each value appears only once (for example, ※x = 1, y = 1§ followed by ※x = 2, y = 2§). The thread name at the start of the line shows that both threads are executing concurrently.
    D. The program prints pairs of values for x and y that are always the same on the same line (for example, ※x = 1, y = 1§). In addition, each value appears only once (for example, ※x = 1, y = 1§ followed by ※x = 2, y = 2§). The thread name at the start of the line shows that only a single thread is actually executing.

    --------------------------------------------------------------------------------------------------------------------------------------------------------

    No.118
    Which statement is true?
    A. To call the wait() method, a thread most own the lock of the current thread.
    B. To call the wait() method, a thread must own the lock of the object on which the call is to be made.
    C. To call the join() method, a thread must own the lock of the object on which the call is to be made.
    D. To call the sleep() method, a thread must own the lock of the object which the call is to be made.
    E. To call the yield() method, a thread must own the lock of the object on which the cal is to be made.

    --------------------------------------------------------------------------------------------------------------------------------------------------------

    No.172
    Exhibit:
    1. public class test(
    2. public int aMethod()[
    3. static int i=0;
    4. i++;
    5. return I;
    6. )
    7. public static void main (String args[]){
    8. test test = new test();
    9. test.aMethod();
    10. int j = test.aMethod();
    11. System.out.printIn(j);
    12.]
    13.}
    What is the result?
    A. Compilation will fail.
    B. Compilation will succeed and the program will print "0"
    C. Compilation will succeed and the program will print "1"
    D. Compilation will succeed and the program will print "2"

    --------------------------------------------------------------------------------------------------------------------------------------------------------

    No.209
    Given:
    5. String foo = "base";
    6. foo.substring(0,3);
    7. foo.concat("ket")
    8.
    Type the value of foo at line 8.


    請教一下這些題目的答案,謝謝



  2. #2
    會員 HarrisonLin 的大頭照
    註冊日期
    2002-04-11
    討論區文章
    611
    你所問的題目裡,有很多都是實地跑一小段程式就可以知道結果的,連這點功夫都不願意花嗎?

  3. #3
    wim
    wim 目前未上線
    會員
    註冊日期
    2003-09-15
    討論區文章
    29
    很感謝您的回覆
    事實上是我的錯,我少說了一些東西
    這個題庫有近500題,
    我例出的題目是我覺得答案有問題
    但是自已寫出來了跑後又覺得好像有問題
    所以我才上來問問
    我當然了解問以前要先爬文
    所以已經先找過了

    不過還是很感謝您的指正
    謝謝您

  4. #4
    會員 HarrisonLin 的大頭照
    註冊日期
    2002-04-11
    討論區文章
    611
    或許你可以把你覺得有疑問的部份提出來。以第一題為例,如果你知道 switch 敘述不接受浮點數的話,就知道答案是 "compile failed",但是這在其他人的眼中看起來就不覺有什麼不對勁,自然就不瞭解你想問的是什麼。所以還是請你詳述你的問題,這樣子的討論也比較效率,也會比較有樂趣!

類似的主題

  1. 【教學】想考 MOS 2002 的認證
    作者:u72566 所在討論版:-- OFFICE 相 關 軟 體 討 論 版
    回覆: 1
    最後發表: 2005-03-03, 11:22 PM
  2. 請問幾個pda的問題
    作者:zegolas 所在討論版:-- NB 筆記型電腦 & PDA 討 論 版
    回覆: 1
    最後發表: 2003-05-13, 02:52 AM
  3. 一個POP3的認證問題...
    作者:jeff1012 所在討論版:-- 網 路 技 術 版
    回覆: 1
    最後發表: 2002-11-02, 05:45 PM
  4. 請問幾個win2000的問題 大家來教教我喔
    作者:dodojpjp 所在討論版:-- Windows 討 論 版
    回覆: 3
    最後發表: 2002-03-23, 12:00 AM
  5. 請問幾個port的用途
    作者:weldon 所在討論版:-- 網 路 技 術 版
    回覆: 2
    最後發表: 2001-07-10, 07:47 AM

 

此網頁沒有從搜尋引擎而來的訪客

發表文章規則

  • 不可以發表新主題
  • 不可以回覆文章
  • 不可以上傳附加檔案
  • 不可以編輯自己的文章
  •