This week's giveaway is in the Groovy forum.
We're giving away four copies of Groovy Fundamentals video training course and have Ken Kousen on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes throwing Exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Groovy Fundamentals video training course this week in the Groovy forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "throwing Exception " Watch "throwing Exception " New topic
Author

throwing Exception

Sweta Pillai
Greenhorn

Joined: Jun 27, 2007
Posts: 28


Why I am not able to throw FileNOtFoundException. As I suppose we cannot
throw More exceptions but less is acceptable.
Manfred Klug
Ranch Hand

Joined: Jun 04, 2007
Posts: 377
Originally posted by Sweta Pillai:


Why I am not able to throw FileNOtFoundException. As I suppose we cannot
throw More exceptions but less is acceptable.


Since the compiler automatically adds the call to the parent constructor. This is the code after compilation:
Chandra Bhatt
Ranch Hand

Joined: Feb 28, 2007
Posts: 1710



Both FileNotFoundException and Exception are checked exceptions.
While the parent class constructor throws the more specific checked
exception, child class must handle or throw that exception or super class
of that.

If you do like:



It is alright!


Welcome to Ranch Sweta!

Thanks,


cmbhatt
Sweta Pillai
Greenhorn

Joined: Jun 27, 2007
Posts: 28
Thanks buddy !
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: throwing Exception