Java
Programming and Technical
Programming
Technical
finally block will get executed whether or not an exception occurs. State True or False
Read Solution (Total 3)
-
- False.
finally block will not execute if an exception occurs before try block.
Example block where finally block is not executed
public class Test
{
public static void main(String args[])
{
System.out.println(10/0);
try
{
}
catch(ArithmeticException e)
{
}
finally
{
System.out.println("finally block");
}
}
}
> javac Test.java
No compilation error.
> java Test
Exception in thread "main" java.lang.ArithmeticException: / by zero
at Test.main(Test.java:5) - 3 years agoHelpfull: Yes(0) No(0)
- Finally block does not executed if exception not occurs.So its false
- 2 years agoHelpfull: Yes(0) No(0)
- TRUE
Yes, the finally block is always get executed unless there is an abnormal program termination either resulting from a JVM crash or from a call to System. exit(). A finally block is always get executed whether the exception has occurred or not - 1 year agoHelpfull: Yes(0) No(0)
Java Other Question