Risky Behaviour — Chapter 11

  1. an Exception is a type of a class that enables you to create objects ( from the inheritance tree)
  2. An exception unless called, is always thrown back to the caller
  3. The compiler checks for everything except RuntimeExceptions — The compiler guarantees: If you throw an exception in your code you must declare it using the throws keyword in your method declaration.
  4. If you call a method that throws an exception (in other words, a method that declares It throws an exception), you must acknowledge that you’re aware of the exception possibility. One way to satisfy the compiler is to wrap the call in a try/catch.
  5. A method can throw an exception when something fails at runtime.
  6. The compiler does NOT pay attention to exceptions that are of type RuntimeException. A RuntimeException does not have to be declared or wrapped in a try/catch (although you’re free todo either or both of those things)
  7. All Exceptions the compiler cares about are called ‘checked exceptions’
  8. Either handle or declare an exception.

try-catch block

A finally block is where you put code that must run regardless of an exception.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Upulie Handalage

Upulie Handalage

Everything in my point of view. Here for you to read on....