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

on exceptions

 
Nihar Ranjan
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is there any strong demarkation on wht kind of exceptions are thrown by jvm and wht kind of exceptions are thrown by programmer.if we explicitly declare an exception type in our code through throw keyword ,and tht exception type is already known to be thrown typically by jvm,wht will happen? will the jvm take rest ?i mean who will take control of throwing this type of exception? jvm or programmer?
 
Gopikrishna Paruchuri
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually it is said that the responsibility of programmer is upto handling only checked exceptions and jvm will take care about the Runtime exceptions and Errors.

But if these exceptions are thrown explicitly then it becomes mandatory for you to catch these exceptions otherwise the program will stop by not finding the appropriate catch blocks and the control will pass to default handler by jvm.
 
Anupam Sinha
Ranch Hand
Posts: 1090
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

is there any strong demarkation on wht kind of exceptions are thrown by jvm and wht kind of exceptions are thrown by programmer


No there is no demarcation of any sort. Though Runtime exceptions can be thrown by the user but shouldn't be and shouldn't actually be handled as well.

Your question sounds a bit ambiguous. The JVM would throw an exception no matter if the user explicitly uses throw or is a result of some code. Consider java exceptions no different from the rest of the exceptions.


i mean who will take control of throwing this type of exception? jvm or programmer?


In case your code resulted in an exception the JVM would throw it for you or if you want you can explcitly ask the JVM to throw an exception for you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic