class Demo5_Extends {
static {
System.out.println("main static..............");
}
{
System.out.println("main {}..............");
}
public Demo5_Extends() {
System.out.println("Demo5 ...........");
}
Father f=new Father();
public static void main(String[] args) {
System.out.println("main..............");
new Demo5_Extends();
System.out.println("main..............");
Son s = new Son();
}
}
class Father extends Object {
A a = new A();
{
System.out.println("........");
}
public Father() {
super();
System.out.println("Father 的构造方法....");
}
static {
System.out.println("Father .....");
}
}
class Son extends Father {
{
System.out.println("..........");
}
B b = new B();
public Son() {
super();
System.out.println("Son 的构造方法.....");
}
static {
System.out.println("Son........");
}
}
class A{
static {
System.out.println("A.............");
}
{
System.out.println("A构造代码块.........");
}
public A(){
System.out.println("A空参构造方法执行..........");
}
}
class B{
static {
System.out.println("B.............");
}
{
System.out.println("B构造代码块.........");
}
public B(){
System.out.println("B空参构造方法执行..........");
}
}
|
|