More than 3000 questions in repository. There are more than 900 unanswered questions. Click here and help us by providing the answer. Have a video suggestion. Click Correct / Improve and please let us know.
Ans. Returning from inside a finally block will cause exceptions to be lost. A return statement inside a finally block will cause any exception that might be thrown in the try block to be discarded.
Help us improve. Please let us know the company, where you were asked this question :
Ans. The regular behavior of exception handling will occur. It will look for any immediate catch handler and if none is provided, it would be transmitted to the callers until a catch handler is found or it's out of main function.
Help us improve. Please let us know the company, where you were asked this question :
Ans. finally will execute in all graceful situations - graceful executions as well as graceful exceptions. The only situation when finally block won't execute is when the app is abruptly stopped, killed or unplugged.
Ans. A finally block of code always executes, whether or not an exception has occurred.The only time finally won't be called is if you call System.exit() or if the JVM crashes first.
Help us improve. Please let us know the company, where you were asked this question :
Ans. final - constant variable, objects cannot be de-referenced, restricting method overriding, restricting class sub classing.
finally - handles exception. The finally block is optional and provides a mechanism to clean up regardless of what happens within the try block. Use the finally block to close files or to release other system resources like database connections, statements etc.
finalize() - method helps in garbage collection. A method that is invoked before an object is discarded by the garbage collector, allowing it to clean up its state.
Ans. The finally keyword is used to create a block of code that follows a try block. A finally block of code always executes, whether or not an exception has occurred.
Help us improve. Please let us know the company, where you were asked this question :
Ans. Yes. Methods invoked from within a finally block can throw an exception. Failure to catch and handle such exceptions results in the abrupt termination of the entire try block.
Help us improve. Please let us know the company, where you were asked this question :
a. try block followed by catch b. try block followed by finally c. try block followed by catch block and then finally d. try block without catch or finally block
Ans. try block without catch or finally block
Help us improve. Please let us know the company, where you were asked this question :