So, till the
JAVA SE5 the rule was: when you override a method, the overriding method has to return exactly the same type as the overridden one!
Beginning with JAVA SE5 the rule is: when you override a method, the overriding method has to return any type that is in relation IS-A with the type returned by the overridden method.
So, till JAVA SE5 i could not do this:
Beginning with JAVA SE5 this is legal, because Number and Integer are covariant return types.
So, in your code the class D extends the class C, so if the overridden method returns C, it's quite legal that the overriding method returns D.
Have a good day, Vadim.