Java Exception Handling Question and Answers

13. When Arithmetic Exception is thrown?
  The Arithmetic Exception is thrown when integer is divided by zero or taking the remainder of a number by zero. It is never thrown in floating point operations.
 
Your Name Your Email-ID
Your Answer
14. What classes of exceptions may be caught by a catch clause?
 
  • A catch clause can catch any exception that may be assigned to the Throwable type.
  • This includes the Error and Exception types.
  • Errors are generally irrecoverable conditions.
 
Your Name Your Email-ID
Your Answer
15. When is finally block NOT called?
 
  • Finally block is NOT called in following cases: if the JVM exists while the try or catch code is being executed. This may happen due to System.exit() call.
  • If the thread executing the try or catch code gets interrupted or killed. In this case, the finally block may not execute although the application keeps working.
  • If an expression is thrown in finally block is not handled. In this case, the remaining code is finally block may not execute.
 
Your Name Your Email-ID
Your Answer
16. What is difference between throw and throws keyword in Java?
  throws keyword is used with method signature to declare the exceptions that the method might throw whereas throw keyword is used to disrupts the flow of program and handing over the exception object to runtime to handle it.
 
Your Name Your Email-ID
Your Answer
1234 Page 4 of 4