package com.instance.order;
public class FatherClass {
public static String F_S_S = "父类-静态变量";
private String f_s = "父类-变量";
static {
System.out.println(F_S_S);
System.out.println("父类-静态初始化快");
}
{
System.out.println(f_s);
System.out.println("父类-初始化块");
}
public FatherClass() {
System.out.println("父类-构造器");
}
public static void main(String[] args) {
new ChildClass();
}
}
class ChildClass extends FatherClass {
public static String C_S_S = "子类-静态变量";
private String c_s = "子类-变量";
static {
System.out.println(C_S_S);
System.out.println("子类-静态初始化快");
}
{
System.out.println(c_s);
System.out.println("子类-初始化块");
}
public ChildClass() {
System.out.println("子类-构造器");
}
}
答案
父类-静态变量
父类-静态初始化快
子类-静态变量
子类-静态初始化快
父类-变量
父类-初始化块
父类-构造器
子类-变量
子类-初始化块
子类-构造器