class SuperCafe4Java {
public Object get (Object o) {
return ("SuperCafe4Java");
}
}
class SubCafe4Java extends SuperCafe4Java {
public Object get (
String o) {
return ("SubCafe4Java");
}
}
class TestCafe4Java {
public static void main (String[] arguments) {
SuperCafe4Java superFoo;
SubCafe4Java subFoo;
superFoo = new SubCafe4Java();
System.out.println (superFoo.get("super"));
subFoo = new SubCafe4Java();
superFoo = subFoo;
System.out.println (superFoo.get("super"));
}
}
When run, this produces the following output:
SuperCafe4Java
SuperCafe4Java
If the invocation of object is determined at runtime, why it is giving the output.....
we are creating the sub class objects but why it is calling superclass method ???