Day 24 – Exceptions – Java

Download (DOC, Unknown)

• Exceptions

  •  try, catch, throw, finally, throws
  • abortion method of exception handling, not resumption method
  • a try block can have one or more catch blocks
  •  if an exception is thrown, only the first matching catch block is executed
  •  if an exception isn’t handled, it is thrown to the calling method
  •  a finally block is always executed
  •  If there is a finally block, it must be last
  •  exceptions can be thrown: throw new Exception(“some descriptive string”);
  •  If throw is used in a catch block, it throws the original exception to the calling method
  • “throws” is used to specify that a method throws an exception
  • A method that throws an exception it doesn’t try-catch must announce it does so with
  • the throws clause
  •  Calling method must “try-catch” it or also “throws” it

Leave a Reply

Your email address will not be published. Required fields are marked *