java面试知识点汇总3

来源:互联网 发布:产品网络推广方案 编辑:程序博客网 时间:2024/05/16 04:32

代码如下:

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

}
class Father{
static{
System.out.println("Father类被加载。。。。");
}
{
System.out.println("Father 对象被创建了。。。");
}
}
class Son extends Father{
static{
System.out.println("Son类被加载。。。。");
}
{
System.out.println("Son 对象被创建了。。。");
}
}

运行的结果为:
Father类被加载。。。。
Son类被加载。。。。
Father 对象被创建了。。。
Son 对象被创建了。。。

0 0
原创粉丝点击