It is not about whether the exception in the catch block is same or not. You need to see if the exception thrown in the try block satisfies the "is-a" test with respect to the exception class mentioned in the catch block.
For example, in this case, you need to see whether an instance of ArrayIndexOutOfBoundsException is-a MySpecialException? No. So an instance of ArrayIndexOutOfBoundsException cannot be caught by MySpecialException.
If the code in the try block threw an instance of a subclass of of MySpecialException, then it would have been caught by the given catch block.
HTH,
Paul.
About Question enthuware.ocajp.i.v8.2.1385 :
Moderator: admin
-
- Site Admin
- Posts: 10053
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.1385 :
If you like our products and services, please help us by posting your review here.
-
- Posts: 28
- Joined: Sun Oct 25, 2015 10:14 am
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.1385 :
Thank you!
It is clear now.
It is clear now.
Who is online
Users browsing this forum: No registered users and 43 guests