继承面试题

class Father {
    static {
        System.out.println("静态代码块Father");
    }
    {
        System.out.println("构造代码块Father");
    }
    public Father() {
        System.out.println("构造方法Father");
    }
}

class Son extends Father {
    static {
        System.out.println("静态代码块Son");
    }
    {
        System.out.println("构造代码块Son");
    }
    public Son() {
        System.out.println("构造方法Son");
    }
}

public class test {
    public static void main(String[] args) {
        Son myson = new Son();
    }
}

运行结果

 

posted @ 2022-03-01 18:37  Ging2000  阅读(38)  评论(0)    收藏  举报