-6

I am study exceptions in Java and came across this snippet:

public class Test
{
    public int b()
    {
        try
        {
            System.out.println("try block");
            return 0;
        }
        finally
        {
            System.out.println("Finally block!");
        }
     }

     public static void main (String[] args)
     {
          Test t= new Test();
          t.b();
     }
}

Since the finally block is always executed and in this case you have a return 0 before it, will it still be executed? (What exactly would the output be).

user3126119
  • 323
  • 1
  • 3
  • 10

1 Answers1

2

Compliation eRROR AT

System.out.printlnI"Finally block!");
                   ^
                  here

:-)

Rakesh KR
  • 6,357
  • 5
  • 40
  • 55