aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes on exceptions 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 "on exceptions" Watch "on exceptions" New topic
Author

on exceptions

Nihar Ranjan
Greenhorn

Joined: Sep 06, 2006
Posts: 2
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

Joined: Sep 02, 2006
Posts: 6
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.


If you want something you never had, do something you have never done.
Anupam Sinha
Ranch Hand

Joined: Apr 13, 2003
Posts: 1088

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.
 
 
subject: on exceptions