Tuesday, 5 March 2013

Which one returns the value when try return and finally returns are there

This is some tricky question

Lets say below code

public int getValue()
   {
        try
        {
          return 2;
       }
       finally
        {
           return 3;
        }
   }

when called the above method System.out.println(getValue()) what is the output

It always returns thr finally return , i.e the answer is 3

No comments:

Post a Comment