Category: Exception Handling
Difference between throw and throws keyword? throw keyword Sometimes we can create exception object explicitly we can handover to the JVM manually. For this, we have to use Throw keyword. Example:- throws new AirthmeticException(“/by zero”); Hence the main objective of Throw keyword is to handover our created exception object to . . . Read more
Difference between final & finally & finalize keyword? The keyword final is an access modifier, finally is a block and finalize is a method. The keyword final is applicable to the classes, variables and methods of the classes finally is a block associated with the try catch block that is . . . Read more
What is finally block in Java? It is not recommended to maintain cleanup code inside try block because there is no guarantee for the execution of every statement inside the try block. It is not recommended to maintain cleanup code inside the catch block. Because if there is no exception . . . Read more
What is Exception and Exception hierarchy in Java? Throwable class act as the root for Java Exception Hierarchy. A throwable class defines two child classes Exception Error Exception An unexpected unwanted even that disturbs normal flow of the program is called an exception. It is highly recommended to handle the . . . Read more
What is the checked and unchecked exception? The exceptions which are checked by the compiler for smooth execution of the program are called checked exceptions. In our program, if there is a chance of raising checked exception then compulsory we should handle that checked exception either by try-catch or by . . . Read more
Explain Default exception handling in Java? Inside a method, if any exception occurs the method in which it is raised is responsible to create exception object by including the following information. Name of exception Description of exception Location at which exception occurs(Stack trace). After creating exception object method handover that . . . Read more
What is Exception and Runtime stack mechanism? An unexpected unwanted even that disturbs normal flow of the program is called an exception. It is highly recommended to handle the exceptions and the main objective of exception handling is graceful termination of the program. Exception Handling doesn’t mean repairing an exception. . . . Read more