Anonymous

Briefly Explain What Is Exception And Give A Simple Example In Java Programming?

1 Answers

Alongbar Daimary Profile
An Exception is an abnormal situation that is created or caused because of runtime error.  If the exception is not handled or caught properly , the Interpreters will display an error message or will terminate the program unexpectedly. This situation can be handled using try... Catch and alternate necessary action can be taken.  Exception Handling Example:   class test{ public static void main(String[]ar){ int a=100; int b=2; int c=0; try{ c=a/(b*c); //Error divided by zero. Exception generated. } catch(ArithmaticException E) // Exception is caught Here. { System.out.println(E); c=a/b; //alternate solution is done here. } finally { System.out.println("Result: " + c); } } }

Answer Question

Anonymous