Hi Arora,
I hope you would have idea of "covariant return" that is allowed with
Java 5.0;
Overriding methods can return the subtype of the return type of the overridden method. Suppose Parent class SpecialNumber named getNumber that returns "Number"
and another class MagicalNumber extends the class SpecialNumber like:
Java 5.0 or so compiler won't complain about this and compile FINE!
But to allow us the advantage of covariant return, compiler has to do one extra work. Ask what? That is the bridge method.
Parent class method returns number and child class method returns Double.
Return type mismatch; for that compiler adds a method with the same
signature and return type inside the child class.
Got it?
Regards,
cmbhatt
[ April 27, 2007: Message edited by: Chandra Bhatt ]