No in this case the finally block will not execute because when you say System.exit (0); the control immediately goes out of the program, and thus fin ...
Search results for java
There are two ways to handle exceptions,
1. By wrapping the desired code in a try block followed by a catch block to catch the exceptions. and
2. Li ...
It is not necessary that each try block must be followed by a catch block. It should be followed by either a catch block OR a finally block. And whate ...
What happens to an unhandled exception?
Posted by Devin
One can not do anytihng in this scenarion. Because Java does not allow multiple inheritance and does not provide any exception interface as well.
[So ...
If I want an object of my class to be thrown as an exception object, what should I do?
Posted by Devin
The class should extend from Exception class. Or you can extend your class from some more precise exception type also.
[Source: JAGAN MOHAN "Intervie ...
How to create custom exceptions?
Posted by Devin
Your class should extend class Exception, or some more specific type thereof.
[Source: JAGAN MOHAN "Interview questions bible"]
[Source: JAGAN MOHAN "Interview questions bible"]
If I write return at the end of the try block, will the finally block still execute?
Posted by Devin
Yes even if you write return as the last statement in the try block and no exception occurs, the finally block will execute. The finally block will ex ...
What are runtime exceptions?
Posted by Devin
Runtime exceptions are those exceptions that are thrown at runtime because of either wrong input data or because of wrong business logic etc. These ar ...
