File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

It is concerned to exception handling

 
KS(Bangalore)
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
public void perform() throws ArthimaticException
{
some code
}
whenever this method is being acessed this arthimatic exception should b caught but ArthimaticException is a RuntimeException.AS per theory even we should not care of these RuntimeExceptions it should work.Can u clarify the diffrence between CheckedExceptions and UncheckedExceptions?
Thanks in Advance
KS(Bangalore)
 
Michael Matola
whippersnapper
Ranch Hand
Posts: 1797
4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Closing thread in Orion and moving to Java in General (Beginner).
Also, KS(Bangalore, Please adjust your displayed name to meet the JavaRanch Naming Policy. You can do so here.
Have you tried searching the forums for previous posts on checked and unchecked exceptions?
[ August 13, 2002: Message edited by: Michael Matola ]
 
Marilyn de Queiroz
Sheriff
Posts: 9059
12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

whenever this method is being acessed this arthimatic exception should b caught but ArthimaticException is a RuntimeException.

If the code in the method throws an ArithmeticException, this method will pass it along to the calling method where it may or may not be caught, depending on the code in the calling method. The fact that this is a RuntimeException is irrelevant to this sequence of events.

AS per theory even we should not care of these RuntimeExceptions it should work. Can u clarify the diffrence between CheckedExceptions and UncheckedExceptions?

A RuntimeException is an exception that the programmer should be able to handle by checking in advance ... for example, verify that the divisor will never be zero before you use it as the denominator the int.

A checked exception is one that the programmer may have no control over. Good examples are found in IO. StreamCorruptedException, FileNotFoundException, EOFException ...
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
AS per theory even we should not care of these RuntimeExceptions it should work.
The advice I've read usually argued that Unchecked Runtime Exceptions were generally not supposed to be caught and handled. They indicate a mistake in the program and the program should have been written to prevent such errors. Checked exceptions should be caught and handled as they often represent problems that the programmer does not have control over and the program should be reasonably able to recover from these problems.
Usually, these same advice givers agreed that the situation is not quite that black and white. For example, if a program gets input from the user in the form of a String that represents some integer value (say "1234"), the program could step through each character of the String and verify that it does indeed form an integer before using Integer.parseInt( String ) to get the number, thus avoiding the possible throwing of a Runtime Exception. But, most all programs with this type of conversion that I've seen just go straight to Integer.parseInt( String ) inside a try block and reasonably handle the possible Runtime Exception in a catch block.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic