父类
public class Person {
String name;
int age;
}
子类
public class Student extends Person{
String school;
}
测试类
public class Test {
public static void main(String[] args) {
Person p =new Student();
p.name="张三";
((Student)p).school="北大";
Person 通过对Student对象的引用,可以对Student对象指向的栈中的地址(假设0x111111),这个变量是继承来的,但是如果Person想访问Student中的变量就要采用强制转换,因为是由大到小访问的,所以person又得到student中的另一个指向栈中的地址(0x222222)这个地址是指向Student内的scool变量