Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

throwing Exception

 
Sweta Pillai
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Why I am not able to throw FileNOtFoundException. As I suppose we cannot
throw More exceptions but less is acceptable.
 
Manfred Klug
Ranch Hand
Posts: 377
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1710
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



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,
 
Sweta Pillai
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks buddy !
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic