Which block among try, catch, and finally is optional in exception handling?

  • All of them
  • catch
  • finally
  • try
In Java exception handling, the finally block is optional. The try block is used to enclose the code that may throw an exception, the catch block is used to handle the exception if it occurs, and the finally block is executed whether an exception occurs or not.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *