/**
 * @author aRu
 * @date 2021/7/27 9:26
 */
class DemoFather{
    public DemoFather(){
        System.out.println("father构造函数");
    }

    static{
        System.out.println("father静态代码块");
    }

    {
        System.out.println("father构造代码块");
    }

    public void fatherMethord(){
        System.out.println("father方法");
    }

}

public class Demo4 extends DemoFather{
    public Demo4(){
        System.out.println("son构造函数");
    }

    static{
        System.out.println("son静态代码块");
    }

    {
        System.out.println("son构造代码块");
    }

    public void fatherMethord(){
        System.out.println("son重写方法");

    }

    public void sonOnlyMethord(){
        System.out.println("son独有方法");
    }

    public static void main(String[] args) {
        Demo4 demo4 = new Demo4();
        demo4.fatherMethord();

    }
}

执行结果

father静态代码块
son静态代码块
father构造代码块
father构造函数
son构造代码块
son构造函数
son重写方法

Process finished with exit code 0