look at the scope.
class Foo{
public void print(){
System.out.println("this is Foo");
}
}
class Fooer extends Test{
public void print(){
System.out.println("this is Fooer");
}
}
public class RunFoo{
public static void main(
String [] args){
SubTest subtest = new SubTest();
Test test = subtest;
test.print();
}
}
I thought it would print "Foo" but in fact it printed "Fooer".It seemed that the Fooer is not up cast to Foo,but why?