Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

mock question doubt

 
raja kanak
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
13) public void divide(int a, int b) {
try {
int c = a / b;
}
catch (Exception e) {
System.out.print("Exception ");
} finally {
System.out.println("Finally");
}
1) Prints out: Finally
2) Prints out: Exception
3) Prints out: Exception Finally
4) No output
4tests.com says the answer is 3.
But i think it is 4 (assuming a=1; b=1)

Am i right?
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The output will always include the word Finally.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic