1.

What is an exception? How are exceptions handled in java? Explain with example

Answer»

An error situation that is unexpected in the program execution and causes it to terminate unexpectedly is called an exception. 

For example Division by zero exception: 

try 

int quotient = divide(10,0); 

System.out.println(quotient); 

catch (Exception e) 

System.out.println(e.getMessage()); 

}



Discussion

No Comment Found

Related InterviewSolutions