answersLogoWhite

0

the errors arriving during the execution of a program when there is a mistake of the programmer in applying the correct mathematical logic

eg: int a= 5;

int b=0;

System.out.print(a/b);

System.out.print("correct answer");

in this eg. a runtime error will be shown and to remove it we can use try catch block

User Avatar

Wiki User

13y ago

Still curious? Ask our experts.

Chat with our AI personalities

BeauBeau
You're doing better than you think!
Chat with Beau
ReneRene
Change my mind. I dare you.
Chat with Rene
RafaRafa
There's no fun in playing it safe. Why not try something a little unhinged?
Chat with Rafa
More answers

ArithmeticException, as the name implies denotes a general arithmetic error such as diving by zero.

User Avatar

Wiki User

12y ago
User Avatar

Add your answer:

Earn +20 pts
Q: What is arithmeticexception?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

A program to explain the Exception Handling mechanisms in Java using the keywords try catch and finally?

Here is a code snippet illustrating exception handling: try { int a= 3 / 0 ; } catch ( ArithmeticException e ) { System.out.println ("An ArithmeticException has occured"); } finally { // some code }


What are the errors in object oriented program?

In Java, errors that arise during the execution of the program are more formally referred to as Exceptions. Exceptions can be handled using try catch blocks. Here is an example : try { int answer = 42 / 0 ; } catch ( ArithmeticException e ) { e.printStackTrace(); }


What a java program for arithmetic operations between two integers?

public static void main(String[] args) { int a = 5; int b = 10; int c; c = a + b; // addition c = a - b; // subtraction c = a * b; // multiplication c = a / b; // division }


Define an exception called NoMatchException that is thrown when a string is not equal to Symbiosis Write a Java program that uses this exception?

import java.util.Scanner; class NoMatchException extends Exception { static void method() throws Exception{ String s = "India"; String s2 = " "; try { if (!s.equals(s2)){ throw new NoMatchException(); //System.out.println("Strings are equal"); } else { System.out.println("Strings are equal"); //throw new NoMatchException(); } } catch(NoMatchException ne){ System.out.println("Exception Found For String"); } finally { System.out.println("In Finally Block"); } } } public class BasicException { static void myMethod(int x, int y) throws Exception{ try { if(x < y ) { System.out.println("Y is greater then X"); throw new Exception(); } else System.out.println("Y is smaller"); } catch(Exception ex) { System.out.println("exception found"); //System.out.println(ex.toString()); } finally { System.out.println("FINALLY block"); } } public static void main(String args[]) throws Exception{ Scanner s = new Scanner(System.in); int d, a, x, y; System.out.println("Enter the value of x and y"); x = s.nextInt(); y = s.nextInt(); try { BasicException.myMethod(x , y); }catch(Exception e) { System.out.println("main method exception"); System.out.println(e.toString()); } try { NoMatchException.method(); } catch(NoMatchException e) { System.out.println("Exception Caught"); } try{ d=0; a=42/d; System.out.println("This will not be printed."); } catch(ArithmeticException e){ System.out.println("Division by zero."); } } }


What is throw keyword in java?

The throw keyword is used from within a method to "throw" an exception to the calling method. In order to throw an exception, the method signature must indicate that it will throw an exception. For example: public void foo() throws Exception { } When you want to actually throw the exception, you can do it a few different ways: throw new Exception("Exception message"); or from within a catch block ( catch(Exception ex) ): throw ex;