wood burning stoves 2.0*
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
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: 1707



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 !
 
jQuery in Action, 2nd edition
 
subject: throwing Exception
 
Similar Threads
Exceptions doubt
Overridden method and exceptions
method overriding
In Constructor giving Exception
Overriding a method that throws an Exception.