Java筆試題

1. Java中集合類型包含ArrayList,LinkedList,HashMap等類,下面描述錯(cuò)誤的是( )
A. ArrayList和LinkedList均實(shí)現(xiàn)了List接口
B. 添加和刪除元素時(shí),ArrayList的表現(xiàn)更佳
C. ArrayList的訪問(wèn)速度比LinkedList快
D. HashMap的實(shí)現(xiàn)MAP接口,它允許任何類型的鍵和值對(duì)象并允許將null作為鍵或值

2. 0.6332的數(shù)據(jù)類型是( )
A. float B. double C. Float D. Double

3.下面程序的輸出是( )

    String s1 = new String("hello");
    String s2 = "hello";
        
    System.out.print(s1 == s2);
    System.out.print(",");
    System.out.print(s1.equals(s2));

A. true, false B. false,true C. false,false D. true,true

4. 請(qǐng)寫出下面程序的輸出

public class Example {
    String str = new String("good");
    char[] ch = { 'a', 'b', 'c' };

    public static void main(String args[]) {
        Example ex = new Example();
        ex.change(ex.str, ex.ch);
        System.out.print(ex.str + " and ");
        System.out.print(ex.ch);

    }

    public void change(String str, char ch[]) {
        str = "test ok";
        ch[0] = 'g';
    }
}

**5.請(qǐng)寫出下面程序的輸出 **

public class Person {
    String name;

    public Person() {
        print();
    }

    public Person(String name) {
        this.name = name;
        print();
    }

    public void print() {
        System.out.println("p:" + name);
    }

    public static void main(String[] args) {
        new Child("kitty");
    }
}

class Child extends Person {
    Person father;

    public Child(String name) {
        System.out.println("new child");
        this.name = name;
        father = new Person("F:" + name);
        print();
    }

    @Override
    public void print() {
        System.out.println("c:" + name);
    }

    public Child() {
        print();
    }
}

6.創(chuàng)建線程的有哪幾種方式?

7.請(qǐng)寫一個(gè)單例類。

8.請(qǐng)使用Java語(yǔ)言實(shí)現(xiàn)冒泡算法。

9.請(qǐng)畫出TCP/IP協(xié)議的三次握手過(guò)程。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容