A

Admin • 828.03K Points
Coach

Q. 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
  • (D) One Two D. Compilation Error
  • Correct Answer - Option(C)
  • Views: 15
  • Filed under category Java
  • Hashtags:

Explanation by: Admin
Finally block will execute irrespective of return statement in try block.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.