posted 19 years ago
There are three main reasons:
1) To ensure that for subsubclasses which eventually implement the method, the return type is narrowed to a subclass of the return type specified by the superclass.
eg:
2) As already mentioned by Tia, to reduce the number of exceptions thrown by classes derived from the subclass, BUT ALSO to restrict the exceptions thrown by these classes' implementation to subclasses of the Exceptions declared in abstract method declaration in the superclass.
3) As already mentioned by Hamid and Tia, to increase the accessibility of the method in classes derived from the subclass - ie: from default or protected to coderanch.
Cheers,
Tim
It's just what I reckon... ...but it's what I reckon.