Unchecked exceptions in Java are exceptions that do not require explicit handling or declaration by the programmer. These exceptions are subclasses of
RuntimeException and its subclasses.
The key characteristics of unchecked exceptions
- Not Checked by Compiler: Unlike checked exceptions, the Java compiler does not enforce the handling or declaration of unchecked exceptions. This means that the code will compile even if the programmer does not catch or declare these exceptions.
- Runtime Exceptions: Unchecked exceptions are often referred to as runtime exceptions because they typically occur at runtime during the execution of a program.
Examples of Unchecked Exceptions include:
ArithmeticException: It is thrown when an arithmetic operation produces an exception, such as division by zero.
ArrayIndexOutOfBoundsException: This exception occurs when trying to access an array element with an invalid index.
ClassCastException: It is thrown when an object is cast to a class of which it is not an instance.
IndexOutOfBoundsException: This exception is raised when accessing a collection with an invalid index.
NullPointerException: It is thrown when trying to access a reference variable that is null.
NumberFormatException: This exception occurs when trying to convert a string to a numeric type, but the string does not have the appropriate format.
StringIndexOutOfBoundsException: It is thrown when trying to access a character of a string with an invalid index.
UnsupportedOperationException: This exception is thrown when trying to perform an operation that is not supported by the object.
|Analog and Memory Layout Design Forum|
|Physical Layout Design Forum|
|RTL & Verilog Design Forum|
|Analog Layout Design Interview Questions||Memory Design Interview Questions|
|Physical Design Interview Questions||Verilog Interview Questions|
|Digital Design Interview Questions||STA Interview Questions|