Question: I am new to Java language and cannot understand the behavior of finally block in this program. This program should exit after printing BC whereas it is printing BCD. Please help. 

```
class Main 
{  
    public static void main(String [] args) 
    {
        try 
        {
            badMethod();  
            System.out.print("A"); 
        }  
        catch (Exception ex) 
        {
            System.out.print("B");  
        } 
        finally 
        {
            System.out.print("C"); 
        } 
        System.out.print("D"); 
    }  
    public static void badMethod() throws Exception
    {
        throw new Exception(); /* Line 22 */
    } 
}

```

Answer: 
The `finally` block doesn't finalize the program, it just ensure to execute every time the try catch block runs whereas there is an exception or not..
Which is correct. The above code will.

1. Try to execute `badMethod` and will fail
2. Execute the code in `catch`
3. Execute the code in `finally`
4. Continue in execution - print out the D