Concepts of Exceptions in Java

Explain the concepts of Exceptions in Java.

Exceptions are errors that occur at runtime and disrupt the normal flow of execution of instructions in a program.

An exception object is created by the method in which an error occurs which is then handed over to the runtime system. This process is called throwing an exception. The object contains the details of the error, its type, etc.

An exception handler is the code that executes after an exception is encountered. The runtime method searches the call stack to find an appropriate method containing the code for handling the exception. The runtime system after receiving the exception tries to find a suitable way to handle it.

When the type of exception thrown matches the type of exception that can be handled, the exception is passed on to the handler so as to catch the exception. The three types of exceptions are:
checked exceptions, errors and runtime exceptions.
What is class loader? Purpose of Bootstrap class loader.
What is class loader? Purpose of Bootstrap class loader - Class loader finds and loads the class at runtime. Java class loader can load classes from across network...
What is a TreeSet class?
What is a TreeSet class? - TreeSet class is used to store large amount of data and uses tree for storage.....
String object is immutable, Explain.
String object is immutable, Explain. - This means once you have created String object and assigned a value, you can’t change the value of the object....
Post your comment