What is Arithmetic Exception in Java?




Asked on February 09, 2015
Can anyone please give any example??


Replied on February 09, 2015
When any number is divided by zero then Arithmetic exception raised. To know more about exception please refer this URL...
http://www.concretepage.com/interview/java-interview/interview-questions-core-java-exceptions-handling

//Arithmetic Exception Example 

package programs;

public class TestEx1 {
public static void main(String[] args) {
int a=20/0;
System.out.println(a);
}

}




Replied on February 09, 2015
Output of the above example...

Exception in thread "main" java.lang.ArithmeticException: / by zero
at programs.TestEx1.main(TestEx1.java:7)


Write Answer











©2024 concretepage.com | Privacy Policy | Contact Us