aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes mock question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "mock question" Watch "mock question" New topic
Author

mock question

V Gala
Ranch Hand

Joined: Aug 06, 2007
Posts: 113
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");
}

Prints out: Finally
Prints out: Exception
Prints out: Exception Finally
No output
ans is Exception finally
can anyone explain me why ans is not finally
Thanks in Advance
Ameen khan
Ranch Hand

Joined: Jun 10, 2007
Posts: 52
Question is incomplete you didn't mention what values of a and b are:

if exception is thrown in try then catch is executed.then finally block will run. otherwise only finally will be printed
[ August 22, 2007: Message edited by: Ameen khan ]

SCJP 5.0<br />Next-> I Don't Know
Muthukumar Chellappa
Greenhorn

Joined: Aug 02, 2007
Posts: 9
Originally posted by Ameen khan:
Question is incomplete you didn't mention what values of a and b are:

if exception is thrown in try then catch is executed.then finally block will run. otherwise only finally will be printed

[ August 22, 2007: Message edited by: Ameen khan ]
Muthukumar Chellappa
Greenhorn

Joined: Aug 02, 2007
Posts: 9
you are not mention which parameters passed to a, b in the method. so it is not possible to say the answer.
one point:
1) Exception arises catch and finally block executed.
2) No Exceptions are arised only finaly block executed
Gitesh Ramchandani
Ranch Hand

Joined: Feb 28, 2007
Posts: 274
Probably it is a "divide by zero" which throws the exception, so you are getting the output as
Exception
finally
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: mock question
 
Similar Threads
q
mock question doubt
Question from 4tests.com
Question
How do you answer such questions?