aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes doubt!! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "doubt!!" Watch "doubt!!" New topic
Author

doubt!!

sriram gupta
Ranch Hand

Joined: Aug 09, 2001
Posts: 39
hi all (once again )
in velmurugan notes it is given that static initializer cannot pass on the checked exceptions. they have to catch and handle them...
i am not sure what does it means.. can anybody tell me about this..
thanks in advance
bye
Bryan Timmins
Ranch Hand

Joined: Mar 26, 2001
Posts: 48
Where in the notes is that printed? Maybe mine is outdated...
Look in the API for "ExceptionInInitializerError", which is suited towards dealing with exceptions in static initializers. Perhaps he is simply reminding that exceptions can be thrown in static initializers.


<a href="http://www.bryantimmins.com" target="_blank" rel="nofollow">Bryan Timmins</a> <br />SCJP2
Vanitha Sugumaran
Ranch Hand

Joined: Apr 11, 2001
Posts: 356
Hi Sri,

Straight from Khalid & Rolf's book.
A static block cannot pass on checked exceptions as static blocks cannot be called explicitly, and therefore there is nothing to handle the exceptions


Example code:

If you add try, catch block then there will be no error.

Hope this helps,
Vanitha.
sriram gupta
Ranch Hand

Joined: Aug 09, 2001
Posts: 39
thanks vanitha,
now it is clear....
but there is one more point which is not very clear to me... it is that
"instance initializers can throw any exception in annonymous class"
if u can tell me about this too it will be very useful...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: doubt!!