This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
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

Correct me if I wrong

Mahtab Alam
Ranch Hand

Joined: Mar 28, 2012
Posts: 354

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: 1595
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

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.

Matthew Brown

Joined: Apr 06, 2010
Posts: 4541

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:
subject: Correct me if I wrong
It's not a secret anymore!