• 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
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

Exceptions thrown by JVM or programmatically

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,

can anyone explain here the difference b/w Exceptions thrown by virtual machine or programmatically.
It's an important topic of SCJP 5 objective 2.6. I read this topic in K&B twice but confused:
why/how ArrayIndexOutOfBoundsException is thrown by JVM and IllegalArgumentException programmatically.? Like this,why/how NullPointerException thrown by JVM and NumberFormatException programmatically?

thanks
 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I can see it that way:
Exceptions thrown by JVM are those which are its response to events taking place under JVM's control - like ArrayIndexOutOfBoundsException is thrown because the JVM has detected an attempt to access an element which it by no means can reach for. On the other hand, my view about exceptions thrown programatically is such that programmers take into account some rules about their methods' arguments which must be abode by because only then the method's logic will work correctly and that's the way in which callers are informed and given a possibility to extract and handle improper use of some situations - like IllegalArgumentException or NumberFormatException.

Regards,
Paul
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Note that there is no clear distinction between exceptions that are always thrown by the JVM and always thrown "programmatically".

There are some exceptions (for example, all the exceptions that end in ...Error) that are usually thrown by the JVM itself instead of by a user program, but in principle your program could also throw these exceptions "programmatically", by using a throw statement.
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hope this will help

https://coderanch.com/t/252956/java-programmer-SCJP/certification/JVM-Exception-Programmatic-Exception

https://coderanch.com/t/265557/java-programmer-SCJP/certification/Exceptions-thrown-programatically-or-JVM
 
reply
    Bookmark Topic Watch Topic
  • New Topic