fbpx

What are checked and unchecked exceptions in Java? Provide examples of each.

  • Checked exceptions: These are exceptions that are checked at compile-time. They must be either caught using a try-catch block or declared using the "throws" keyword. Example: IOException.
  • Unchecked exceptions: These exceptions are not checked at compile-time and are subclasses of RuntimeException. They do not need to be caught or declared. Example: NullPointerException

# Dream job to realty