面试题10:看程序写结果(继承)

来源:互联网 发布:虚拟机安装mac os x 编辑:程序博客网 时间:2024/04/27 18:32

看程序写结果


class Father{static{System.out.println("静态FU");}{System.out.println("构造代码FU");}public Father(){System.out.println("构造方法FU");}}class Zi extends Father{static{System.out.println("静态ZI");}{System.out.println("构造代码ZI");}public Zi(){System.out.println("构造方法ZI");}}class Test{public static void main(String[] args){Zi z=new Zi();}}
/*

结果是:静态FU,静态ZI,构造代码FU,构造方法FU,构造代码ZI,构造方法ZI

*/

0 0
原创粉丝点击