Hi friends,
The output of this program is 5
but according to me it should be 6.
Please help.
Thanks in Advance.
public class CovariantTest
{
public A getObject()
{
return new A();
}
public static void main(
String []args)
{
CovariantTest c1=new SubCovariant();
System.out.println(c1.getObject().x);
}
}
class A
{
int x=5;
}
class B extends A
{
int x=6;
}
class SubCovariant extends CovariantTest
{
public B getObject()
{
return new B();
}
}