Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

q

 
JayaSiji Gopal
Ranch Hand
Posts: 303
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
public void divide(int a, int b) {
try {
int c = a / b;
}
catch (Exception e) {
System.out.print("Exception ");
} finally {
System.out.println("Finally");
}

Prints out: Finally
Prints out: Exception
Prints out: Exception Finally
No output

i answered 1st option, but the correct option is 3.
The 3rd option wud be correct, if b = 0.
No such condition is mentioned here.

Wht shd be the correct answer and y?
 
Joe Borderi
Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you tried to compile and run the code? Use some test cases and test the output.
 
Jay Ashar
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not sure if there is any correct answer to your question, unless you supply a value of a and b variables.
[ November 22, 2004: Message edited by: Mike Saloni ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic