变量(实例变量、类变量、常量)及类方法均与编译时类型相关
实例方法与运行时类型相关(故而产生多态)
class A
{
public static int h = 10;
public int n = 10;
public static final int m = 10;
public static void put()
{
System.out.println("A");
}
public void put1()
{
System.out.println("A1");
}
}
public class Solution extends A
{
public static int h = 100;
public int n = 100;
public static final int m = 100;
public static void put()
{
System.out.println("Solution");
}
public void put1()
{
System.out.println("Solution1");
}
public static void main(String[] args)
{
A a = new Solution();
System.out.println(a.h);//类变量 10
System.out.println(a.n);//实例变量 10
System.out.println(a.m);//常量 10
a.put(); //类方法 A
a.put1(); //实例方法 Soultion1
}
}