A sub class probabaly has more properties then that of super class , then why I am able to catch all exceptions by making the object of Exception class insted of its sub classes (while handling any exception by try,catsh,finally statement)?

Showing Answers 1 - 3 of 3 Answers

Kamesh

  • Mar 30th, 2006
 

A derived class object can be assigned to any of the parent class object.  In the same way any subclasses of Exception class can be caught by Exception e.  But the reverse is not true..  A parent class object cannot be assigned to a derived class object without explicit cast.

  Was this answer useful?  Yes

salil.kaul

  • Apr 10th, 2006
 

While a reference to the general Exception class can catch exceptions of its sub classes it cannot refer to the properties (members and methods ) unique to the sub class

  Was this answer useful?  Yes

Guest

  • Apr 10th, 2006
 

While a reference to the general Exception class can catch exceptions of its sub classes it cannot refer to the properties (members and methods ) unique to the sub class

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions