I was going through K&B chapter2: Object Orientation , when i came across this line : " For the exam , be sure you know that overloaded methods can change the return type but overriding methods can do so only within the bounds of co-varient returns" .
My doubt is :how "overriding methods can do so only within the bounds of covarient returns" .? What it actually means ?
Covariant just means the overridden method can return a subclass of the return type declared in the parent class (This was introduced in Java 5). Tip: Always use the @Override annotation when you override. It will save you tons of grief.
OVERLOAD: "overloaded methods can change return type" (and the method signature must change. This means changing the number of arguments and / or the types)
OVERRIDE: "overridden methods must have the same return type OR covariant return type