标签:
abstract classPerson{
String name;
int age;
void introduce(){
System.out.println("我的名字是"+ name +",我的年龄是"+ age);
}
abstract void eat();
}
classChinese extends Person{
//Person中eat的复写
void eat(){
System.out.println("用筷子吃饭");
}
}
classTest{
publicstaticvoid main(String args []){
//向上转型
Person p =newChinese();
p.eat();
}
}
标签:
原文地址:http://www.cnblogs.com/arroneve/p/5815444.html