Exception handling keyword summary

 Exception handling keyword summary

 

try:-   To maintain risky code.   

catch:- To maintain exception handling code.

finally:- To maintain cleanup code.

throw:- To handover our created exception object to JVM manually.

throws:- To delegate responsibility of exception handling to the caller.   


 Various possible compile time error in exception handling.

  • Unreported exception xxx must be caught or declared to be thrown.
  • Exception xxx has already been caught.
  • Exception xxx is never thrown in body of corresponding try statement.
  • Unreachable statement.
  • Incompatible type.
    • found : test
    • required: java.lang.Throwable
  • try without catch or finally.
  • catch without try.
  • finally without try.

 

Related topic 

 

RAKESH RAKA

I am Rakesh Raka, senior software engineer (JAVA) in Sopra Steria.

Post a Comment (0)
Previous Post Next Post