package com.lovecoding.day10.guanjian03;

class Father {
    private int num = 10; ////子类没有重写方法时 权限修饰符 对变量没有影响
    public int getNum() {
        return num;
    }
}

class Son extends Father{
    public int num = 20;
    public void test(){
        System.out.println(getNum()); // 10
        System.out.println(this.getNum()); //10
        System.out.println(super.getNum()); //10
    }
}
class Daughter extends Father{
    public int num = 20;
    @Override
    public int getNum() {
        return num;
    }
    public void test(){
        System.out.println(getNum());  // 20
        System.out.println(this.getNum()); //20
        System.out.println(super.getNum()); // 10
    }
}
public class Test01 {
    public static void main(String[] args) {
        //子类没有重写方法时 权限修饰符 对变量没有影响
        Son son = new Son();
        son.test();
        System.out.println("--------------------");
        //子类重写方法时 权限修饰符 对变量没有影响 先从本类中查找
        Daughter daughter = new Daughter();
        daughter.test();
    }
}
