亚洲福利精品久久久久91|中文字幕乱码视频网|在线播放国产精品一区二区|亚洲成AV人片女在线观看

<thead id="tzpj5"></thead>
  • <cite id="tzpj5"><listing id="tzpj5"></listing></cite>
    <strike id="tzpj5"><option id="tzpj5"><td id="tzpj5"></td></option></strike>

    IBM Java筆試題和面試題答案(一)

    思而思學(xué)網(wǎng)

    1. 如下代碼

    class A {

    A() { }

    }

    class B extends A {

    }

    哪兩個(gè)說(shuō)明是正確的?

    A. B類的構(gòu)造器應(yīng)該是 public.

    B. B類的構(gòu)造器應(yīng)該是沒(méi)有參數(shù)

    C. B類的構(gòu)造器應(yīng)該調(diào)用this().

    D. B類的構(gòu)造器應(yīng)該調(diào)用super().

    答案:BD

    解析:默認(rèn)構(gòu)造器的修飾符只跟當(dāng)前類的修飾符有關(guān)。 比如B如果是public的,則默認(rèn)構(gòu)造方法是public的。 如果B是默認(rèn)的訪問(wèn)權(quán)限,則構(gòu)造方法相同。 當(dāng)B是內(nèi)部類是,前面也可以有protected,private等,默認(rèn)添加的構(gòu)造方法仍然和類的修飾符一致。

    2. 如下代碼

    public class Test {

    public int aMethod() {

    static int i = 0;

    i ;

    return i;

    }

    public static void main (String args[]) {

    Test test = new Test();

    test.aMethod();

    int j = test.aMethod();

    System.out.println(j);

    }

    }

    輸出結(jié)果是什么?

    A. 0

    B. 1

    C. 2

    D. 編譯失敗

    答案:D

    解析:static在Java語(yǔ)言中的使用有四種:(成員變量、成員方法、代碼塊、內(nèi)部類)

    3. 如下代碼

    int i =1,j =10;

    do {

    if(i > --j) {

    continue;

    }

    } while (i <5);

    System.out.println("i = " i "and j = " j);

    輸出結(jié)果是什么?

    A. i = 6 and j = 5

    B. i = 5 and j = 5

    C. i = 6 and j = 5

    D. i = 5 and j = 6

    E. i = 6 and j = 6

    答案:D

    4. 如下代碼:

    boolean bool = true;

    if(bool = false) {

    System.out.println("a");

    } else if (bool) {

    System.out.println("c");

    } else if (!bool) {

    System.out.println("c");

    } else {

    System.out.println("d");

    }

    輸出結(jié)果是什么?

    A. a

    B. b

    C. c

    D. d

    E. 編譯失敗

    答案:C

    5. 如下代碼:

    public class SwitchTest {

    public static void main(String[] args) {

    System.out.println("value = " switchIt(4));

    }

    public static int switchIt(int x) {

    int j = 1;

    switch (x) {

    case 1: j ;

    case 2: j ;

    case 3: j ;

    case 4: j ;

    case 5: j ;

    default: j ;

    }

    return j x;

    }

    }

    輸出結(jié)果是什么?

    A. value = 3

    B. value = 4

    C. value = 5

    D. value = 6

    E. value = 7

    F. value = 8

    答案:F

    6. 以下數(shù)組的定義,哪三條是正確的?

    A. public int a []

    B. static int [] a

    C. public [] int a

    D. private int a [3]

    E. private int [3] a []

    F. public final int [] a

    答案:A,B,F

    7. 如下代碼:

    class Super {

    public Integer getLenght() { return new Integer(4); }

    }

    public class Sub extends Super {

    public Long GetLenght() { return new Long(5); }

    public static void main(String[] args) {

    Super sooper = new Super();

    Sub sub = new Sub();

    System.out.println(sooper.getLenght().toString() ","

    sub.getLenght().toString() );

    }

    }

    輸出是什么?

    A. 4,4

    B. 4,5

    C. 5,4

    D. 5,5

    E. 編譯失敗.

    答案:A

    8. 在接口中以下哪條定義是正確的? (兩個(gè)答案)

    A. void methoda();

    B. public double methoda();

    C. public final double methoda();

    D. static void methoda(double d1);

    E. protected void methoda(double d1);

    答案:A,B

    9. 如下代碼:

    public void test(int x) {

    int odd = x%2;

    if (odd) {

    System.out.println("odd);

    } else {

    System.out.println("even");

    }

    }

    哪個(gè)描述正確?

    A. 編譯失敗.

    B. "odd" 永遠(yuǎn)被輸出.

    C. "even" 永遠(yuǎn)被輸出

    D. "odd" 輸出x的值,

    E. "even" 輸出x的值

    答案:A

    10. 如下代碼:

    public class X {

    public X aMethod() { return this;}

    }

    public class Y extends X {

    }

    哪兩個(gè)方法能加到Y(jié)類的定義中?

    A. public void aMethod() {}

    B. private void aMethod() {}

    C. public void aMethod(String s) {}

    D. private Y aMethod() { return null; }

    E. public X aMethod() { return new Y(); }

    答案:E,?

    熱門推薦

    最新文章