
    classPerson{String name;int age;void introduce(){System.out.println("我的名字是:"+ name +",我的年龄是:"+ age);}}classStudent extends Person{String address;void study(){System.out.println("我正在学习");}void introduce(){		super.introduce();System.out.println("我的家在"+ address);}}classTest{publicstaticvoid main(String args []){Student s =newStudent();Person p = s;		p.name ="张三";		p.age =20;		s.address = "北京";		p.introduce();//p.study();}}
classTest{publicstaticvoid main(String args []){//Student s = new Student();//Person p = s;Person p =newStudent();Student s =(Student)p;//错误的向下转型//Person p = new Person();//Student s = (Student)p;}}原文:http://www.cnblogs.com/arroneve/p/5815441.html