my dog learned polymorphism*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Correct me if I wrong Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Correct me if I wrong" Watch "Correct me if I wrong" New topic
Author

Correct me if I wrong

Mahtab Alam
Ranch Hand

Joined: Mar 28, 2012
Posts: 252


The exceptions thrown by API methods like NumberFormatException ,IllegalArgumentException,ArrayIndexOutOfBoundsException are programatically thrown.

and JVM thrown exceptions are StackOverflowError,NullPointerException,ClassCast exception
Although we can explicitly through these exceptions

Oracle Java Programmer , Oracle SQL Expert , Oracle Java Web Component Developer
Akhilesh Trivedi
Ranch Hand

Joined: Jun 22, 2005
Posts: 1526
What do you mean by "programmatically thrown" and "JVM thrown"?


Keep Smiling Always — My life is smoother when running silent. -paul
[FAQs] [Certification Guides] [The Linux Documentation Project]
Bhavesh Saraswat
Greenhorn

Joined: Jan 20, 2013
Posts: 18

You can always throw anything which is throwable from your code. Throwable is at the top of the hierachy. So in this way you can throw any exception of error you want from your code and also catch the same. But it is recomonded that you only throw exception or error which is more relevant and easy to understand during debuging.


OCPJP SE6
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4385
    
    8

Mahtab Alam wrote:
The exceptions thrown by API methods like NumberFormatException ,IllegalArgumentException,ArrayIndexOutOfBoundsException are programatically thrown.


Two of them are. ArrayIndexOutOfBoundsException is thrown by the JVM, though, whenever you try to access an array index that doesn't exist.

You can throw any exception programmatically. But some are only thrown that way - meaning that somewhere in the source code (either yours or an API) there's a statement that says "throw new ...".
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Correct me if I wrong