• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ArithmeticException

 
Balaguru Janarthanan
Ranch Hand
Posts: 37
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ArithemeticException is checked exception. True/false.
I thogut the True is the answer. but it is given false. any one pls explain. all runtime exception is not checked exception- pls explain.
 
Stevie Kaligis
Ranch Hand
Posts: 400
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi...,

  1. Checked Exception represent conditions that, although exceptional, can reasonably be expected to occur. Making this exception checked, documents the existence of the exception and ensures that the caller of a method deals with the exception in some way.
  2. Unchecked Exception represent conditions that, generally speaking, reflect errors in your program logic and cannot be reasonably recovered from at run time. for example, the ArithemeticException thrown when you devided a number with integer zero, tells you that your program calculated incorrectly. These are error should be corrected in the program code.

  3. hope that helps
    stevie
 
Balaguru Janarthanan
Ranch Hand
Posts: 37
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So, Stevie, I need not handle this type of runtime errors. Am i right?
 
Stevie Kaligis
Ranch Hand
Posts: 400
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
RuntimeException and Error are the only exceptions you do not need to list in your throws clauses. They are ubiquitous, and every method can potentially throw them. This is why they are unchecked by the compiler.
Note :
The contract defined by throws clause is strictly enforced, you can throw a type of checked exception that has been declared in the throws clause. Throwing any other type of checked exception is invalid.
If a method has no throws clause, it does not mean that any exception can be thrown, it means No checked exceptions can be throw.
regard's
stevie
 
Angela Narain
Ranch Hand
Posts: 327
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Yes , we donot need to handle runtime exceptions.
Anyway , Is there some easy way to remember which exception classes are checked exceptions and which are RuntimeExceptions/unchecked exceptions.

 
jeena jose
Ranch Hand
Posts: 69
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
Unchecked Exceptions:ArithmeticException,NumberFormatException,NullPointerException
checked exceptions: IOException,FileNotFoundException,MalformedURLException,InterruptedException(most common exceptions)
jeena jose
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic