1:静态函数和成员变量都是看父类。
2:非静态成员函数是看子类。
class fu
{
int num = 3;
void show(){
System.out.println("fu show");
}
static void run()
{
System.out.println("fu run");
}
}
class zi extends fu
{
int num = 4;
void show()
{
System.out.println("zi show");
}
static void run()
{
System.out.println("zi run");
}
}
class DuoTaiDemo2
{
public static void main(String[] args)
{
fu a = new zi();
a.show();
a.run();
System.out.println(a.num);
}
}
运行结果: