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
Joined: Mar 25, 2001
Posts: 1721
posted
0
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
Joined: Jul 22, 2000
Posts: 9033
10
posted
0
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.
JavaBeginnersFaq "Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Dirk Schreckmann
Sheriff
Joined: Dec 10, 2001
Posts: 7023
posted
0
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.