Originally posted by Kartik Mahadevan:
But since a subclass has a higher functionality than a base class which means that subclass objects may be having better way of dealing with exceptions than base class so should it not inherit from subclass?
Why inherit from a base class when subclass is there?
"higher functionality"? Exception classes pretty much all have the same funtionality (as defined by the interface they all implement java.lang.Throwable). You might subclass an exception to provide more description about the problem. Look at the subclasses for IOException for example, there a set of exceptions which all describe more specific IO problems (EOF, Socket problems, Unknown Host etc.). How you handle those is up to you. You might just want to know know that the IO operation failed, in which case catch the super class IOException. Alternatively it might be expedient to have your application respond differently if the IO operation fails in a specific way, in which case you would catch the sub class of IOException
first, and IOException second. Make sense?