Can we have return statement in finally clause? What will happen?



Can we have return statement in finally clause? What will happen?..

Answer / Ravindra

No, you cannot have a `return` statement inside the `finally` block. The `finally` block is used for ensuring that some cleanup code always executes, whether an exception occurs or not. If you want to exit from multiple blocks (including the `try`, `catch`, and `finally` blocks), use the `break` statement instead.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Core Java Interview Questions

Name the class that used to read objects directly from a stream?

4 Answers   Wipro,


Explain the difference between comparator and comparable in java?

1 Answers  


What is the purpose of having the concept of overloading?

7 Answers   Ness Technologies,


What is a null class?

1 Answers  


What is difference between class and object in java?

1 Answers  


What is local declaration?

1 Answers  


What is externalizable interface?

1 Answers  


What is string in java with example?

1 Answers  


How a variable is stored in memory?

1 Answers  


What are dot operator queries?

1 Answers   Atos Origin,


What is collections framework?

1 Answers  


how to handle exceptions in ejb?

1 Answers   HCL,


Categories