日期:2014-05-20 浏览次数:20791 次
class Person
{
String name;
int age;
public void say()
{
System.out.println("I am fater");
}
public void work()
{
System.out.println("I hava a job");
}
}
class Child extends Person
{
public void say()
{
System.out.println("I am child");
}
public void dance()
{System.out.print("I can dance");}
}
public static void main(String[] args) {
// TODO Auto-generated method stub
Person per=new Child();
per.say();
per.work();
Child ch=(Child)per;
ch.dance();
ch.say();
//为什么下面会报错呢?
Child ch1=(Child)new Person();
}