<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    隨筆-61  評(píng)論-13  文章-19  trackbacks-0

    2.下面代碼的輸出是什么?一共在內(nèi)存中生成了幾個(gè)String對(duì)象?為什么?
    String s1 = “aaa”;
    String s2 = “aaa”;
    String s3 = new String(“aaa”);
    String s4 = new String(“AAA”);
    System.out.println(s1 == s2);
    System.out.println(s1 == s3);
    System.out.println(s1.equals(s3));

    3.下列程序在1處是否會(huì)有異常,如果沒有,輸出是什么?是否會(huì)運(yùn)行到2處,如果會(huì),輸出是什么?為什么會(huì)有這樣的結(jié)果?
    public class TestClass {
    public void test1() {
    List list = new ArrayList();
    test2(list);
    System.out.println(list.size()); // 1處
    test3(list);
    System.out.println(list.size()); // 2處
    }

    public void test2(List list) {
    list = null;
    }

    public void test3(List list) {
    list.add(“aaaa”);
    }
    }

    4.請(qǐng)選出下面哪些描述是正確的。
    public class ClassA {
    public synchronized void a(){
    }
    public synchronized void b(){
    }
    }
    2 instances of ClassA had been instantiated obj1 and obj2.
    Which statements about thread are true?
    1)One thread is calling obj1.a(), another thread can call obj1.b().? .
    2)One thread is calling obj1.a(), another thread cannot call obj1.b().?
    3)One thread is calling obj1.a(), another thread can call obj2.b().? .
    4)One thread is calling obj1.a(), another thread cannot call obj2.b().?


    5.下面的程序輸出是什么?為什么?
    public class Parent {
    public void test(ArrayList list) {
    System.out.println("invoke parent's test method");
    }

    public static void main(String[] args) {
    Child a = new Child();
    ArrayList list = new ArrayList();
    a.test(list);
    }
    }

    class Child extends Parent {
    public void test(List list) {
    System.out.println("invoke child's test method");
    }
    }

    6.下面的程序輸出是什么?為什么?
    public class Parent {
    public void test(List list) {
    System.out.println("invoke parent's test method");
    }

    public static void main(String[] args) {
    Child a = new Child();
    ArrayList list = new ArrayList();
    a.test(list);
    }
    }

    class Child extends Parent {
    public void test(List list) {
    System.out.println("invoke child's test method");
    }
    }

    7.仔細(xì)分析下面的程序,寫出程序的輸出結(jié)果。
    public class Parent {
    {
    System.out.println("parent instance block");
    }

    public void test() {
    System.out.println("parent test method");
    }

    static {
    System.out.println("parent static block");
    }

    public Parent() {
    System.out.println("parent constructor");
    test();
    }

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

    class Child extends Parent {

    private static int staticValue = 20;
    private int instanceValue = 20;

    {
    System.out.println("child instance block");
    }

    public void test() {
    System.out.println("child test method");
    System.out.println("static value is: " + staticValue);
    System.out.println("instance value is: " + instanceValue);
    }

    static {
    System.out.println("child static block");
    }

    public Child() {
    System.out.println("child constructor");
    }
    }

    8.下面程序的輸出是什么?
    public class TestException {
    public void test1() {
    int result = test2();
    System.out.println(result);
    }

    public int test2() {
    try{
    String s = null;
    s.substring(0, 1);
    return 1;
    } catch(Exception e) {
    return 2;
    } finally {
    return 3;
    }
    }

    public static void main(String[] args) {
    (new TestException()).test1();
    }
    }

    9.請(qǐng)寫出數(shù)據(jù)庫查詢操作的偽代碼,程序不需要通過編譯,只要思路正確,關(guān)鍵步驟不丟失就可以了。注意異常的捕獲,IO流的關(guān)閉。可能用到的類或接口有(Connection,DriverManager, Statement, PreparedStatement, ResultSet, SQLException)。

    posted on 2006-03-19 23:12 xnabx 閱讀(145) 評(píng)論(0)  編輯  收藏

    只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


    網(wǎng)站導(dǎo)航:
     
    主站蜘蛛池模板: 亚洲精品在线电影| 久久久久亚洲精品美女| 亚洲精品第一综合99久久| 亚洲精品视频免费看| 亚洲黄色中文字幕| 2015日韩永久免费视频播放| 亚洲一区二区在线免费观看| 久久综合给合久久国产免费| 777亚洲精品乱码久久久久久| 最刺激黄a大片免费网站| 亚洲狠狠ady亚洲精品大秀| 午夜性色一区二区三区免费不卡视频 | 国产成人免费午夜在线观看 | 成年男女男精品免费视频网站| 亚洲性猛交xx乱| 免费观看一级毛片| 免费高清A级毛片在线播放| 亚洲国产中文v高清在线观看| h视频在线观看免费| 亚洲av无码一区二区乱子伦as| 一级毛片aaaaaa免费看| 亚洲激情视频图片| 亚洲?V无码乱码国产精品| 日韩精品无码免费专区午夜| 亚洲美女色在线欧洲美女| 国产精品免费看香蕉| 中国好声音第二季免费播放| 亚洲高清资源在线观看| 成人毛片免费视频| 丁香花在线观看免费观看图片 | 亚洲欧洲另类春色校园网站| 免费a在线观看播放| 四虎国产精品免费永久在线| 亚洲免费在线视频观看| 亚洲国产精品一区二区九九 | 亚洲成人一区二区| 91嫩草免费国产永久入口| 免费观看亚洲人成网站| 亚洲av中文无码乱人伦在线播放| 无码永久免费AV网站| 一本岛v免费不卡一二三区|