What will be the output when you compile and execute the following program.
////////////////////////////////////////////
class Base
{
void
test() {
System.out.println("Base.test()");
}
}
////////////////////////////////////////////
public class Child extends Base {
void test() {
System.out.println("Child.test()");
}
static public void main(
String[] a) {
Child anObj = new Child();
Base baseObj = (Base)anObj;
baseObj.test();
}
}
Select most appropriate answer.
a) Child.test()
Base.test()
b) Base.test()
Child.test()
c) Base.test()
d) Child.test()
The answer given is d)
I think c) is the right answer.
Please help.
-Thanks