“I bought this guide a few days ago to prepare for my interview with Oracle. Many of the questions they asked me were from this guide. I found this book absolutely great!”
1.It separates the working/functional code from the error-handling code by way of try-catch clauses.
2.It allows a clean path for error propagation. If the called method encounters a situation it can’t manage, it can throw an exception and let the calling method deal with it.
3.By enlisting the compiler to ensure that “exceptional” situations are anticipated and accounted for, it enforces powerful coding.
4.Exceptions are of two types: Compiler-enforced exceptions, or checked exceptions
Runtime exceptions, or unchecked exceptions
Compiler-enforced (checked) exceptions are instances of the Exception class or one of its subclasses — excluding the RuntimeException branch. The compiler expects all checked exceptions to be appropriately handled. Checked exceptions must be declared in the throws clause of the method throwing them — assuming, of course, they’re not being caught within that same method. The calling method must take care of these exceptions by either catching or declaring them in its throws clause. Thus, making an exception checked forces the us to pay heed to the possibility of it being thrown. An example of a checked exception is java.io.IOException. As the name suggests, it throws whenever an input/output operation is abnormally terminated.
Exceptions are special conditions in a program that leads to abnormal termination of the program. The most common exception is “divide by zero”.
Exception in java can be handled by following methods:
try and catch
throw
throws
finally
An exception is an error situation that terminates a program abnormally…
u already read about checked exceptions.. these situations are checked during compilation and hence need to handled or declared to be thrown(using ‘throws’ keyword)
then there are unchecked exception which are checked only runtime.
eg ArrayIndexOutOfBoundException, ArithmeticException…
When such an error occurs, compiler will search for its handling code. If not found, eventually the JVM(Java virtual machine) handles the error.
1.It separates the working/functional code from the error-handling code by way of try-catch clauses.
2.It allows a clean path for error propagation. If the called method encounters a situation it can’t manage, it can throw an exception and let the calling method deal with it.
3.By enlisting the compiler to ensure that “exceptional” situations are anticipated and accounted for, it enforces powerful coding.
4.Exceptions are of two types:
Compiler-enforced exceptions, or checked exceptions
Runtime exceptions, or unchecked exceptions
Compiler-enforced (checked) exceptions are instances of the Exception class or one of its subclasses — excluding the RuntimeException branch. The compiler expects all checked exceptions to be appropriately handled. Checked exceptions must be declared in the throws clause of the method throwing them — assuming, of course, they’re not being caught within that same method. The calling method must take care of these exceptions by either catching or declaring them in its throws clause. Thus, making an exception checked forces the us to pay heed to the possibility of it being thrown. An example of a checked exception is java.io.IOException. As the name suggests, it throws whenever an input/output operation is abnormally terminated.
Exceptions are special conditions in a program that leads to abnormal termination of the program. The most common exception is “divide by zero”.
Exception in java can be handled by following methods:
try and catch
throw
throws
finally
An exception is an error situation that terminates a program abnormally…
u already read about checked exceptions.. these situations are checked during compilation and hence need to handled or declared to be thrown(using ‘throws’ keyword)
then there are unchecked exception which are checked only runtime.
eg ArrayIndexOutOfBoundException, ArithmeticException…
When such an error occurs, compiler will search for its handling code. If not found, eventually the JVM(Java virtual machine) handles the error.
Leave an Answer/Comment