What are Checked and UnChecked Exception?

What are Checked and UnChecked Exception?

The java.lang.Throwable class has two subclasses Error and Exception. There are two types of exceptions non runtime exceptions and runtime exceptions. Non runtime exceptions are called checked exceptions and the unchecked exceptions are runtime exceptions.

Runtime Exceptions occur when the code is not robust and non runtime exceptions occur due to the problems in environment, settings, etc.

What is checked and unchecked exception?

The exceptions that are not the sub classes of RuntimeException and its sub classes are called checked exceptions. A checked exception forces the developer to handle it. For example, IOException is a checked exception.

The exceptions that are the exceptions of RuntimeException and its sub classes are called unchecked exceptions. The class Error and its subclasses also are unchecked exceptions. An unchecked exception does not force the developer to handle it, either by catch block or by throws clauses. The developer may not predict these exceptions to handle.
For example, ArrayIndexOutOfBoundsException is an unchecked exception.
Java inner classes: What are different types of inner classes?
Java inner classes - Types of inner classes - Local classes, Member classes, Anonymous classes...
Java wrapper classes
What is wrapper classes in Java?, Why do we need wrapper classes in Java?, Features of the Java wrapper Classes...
Java error exception: What is the difference between error and an exception?
Java error exception - Errors are abnormal conditions that should never occur. Not to be confused with the compile time errors....
Post your comment