Vidyalelo
Java Programming · Q45

Exceptions

Programming · Java Programming · question 45

Q45

What will be the output? class MyClass public String test() try System.out.print("One"); return ""; finally System.out.print("Two"); public class Test public static void main(String args[]) MyClass m = new MyClass(); m.test();

A.
One
B.
Two
C.
One Two
Answer
D.
Compilation Error
E.
None of these

Answer: Option C

Solution

Answer: Option C
Solution:

Finally block will execute irrespective of return statement in try block.