Multiple choice technology programming languages

What will be the output of the below code snippet? public class Quiz6 { public static void main(String[] args) { System.out.println(decision()); } static boolean decision() { try { return true; } finally { return false; } } }

  1. True

  2. False

  3. Compilation Error

  4. Run Time Error

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

In Java, when a finally block executes with a return statement, it overrides any return value from the try block. The try block executes return true, but before the method actually returns, the finally block executes and returns false, which overrides the true. The final output is false. Options A, C, and D are incorrect - the finally block's return takes precedence, there's no compilation error, and no runtime error occurs.