• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

on exceptions

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 1090
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
a fool thinks himself to be wise, but a wise man knows himself to be a fool - shakespeare. foolish tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic