This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes Mock Exam Errata and the fly likes MindQ Q31 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Certification » Mock Exam Errata
Bookmark "MindQ Q31" Watch "MindQ Q31" New topic

MindQ Q31


Joined: Feb 02, 2001
Posts: 3
Hi folks
31. Consider the code below:
void myMethod()
{ try
catch( NullPointerException npex )
System.out.println( "NullPointerException thrown " );
catch( Exception ex )
System.out.println( "Exception thrown " );
System.out.println( "Done with exceptions " );
System.out.println( "myMethod is done" );
What is printed to standard output if fragile() throws an IllegalArgumentException?
a) "NullPointerException thrown"
b) "Exception thrown"
c) "Done with exceptions"
d) "myMethod is done"
e) Nothing is printed
According to me the answer should be.. b,c.
But the answers in MindQ site are b,c,d.
I am bit confused here. Please help

Lokesh Mahajan

Joined: Feb 01, 2001
Posts: 22
Hello Dear
This is like this in the example IllegalArgumentException thrown by the method fragile() is cought in the catch block(which prints"Exception thrown"),
than the finally block is executed(results in printing "Done with exceptions"
Now since the exception thrown by the method fragile() is caught by the try & catch block(though not immediate catch block but by the successive catch block)program does not terminates,but
it follows the steps bellow the method so resulting in printing "myMethod is done"
d will not have been option had the exception thrown is not caught & there by terminating the program.
lokesh mahajan

Joined: Feb 02, 2001
Posts: 3
Hi Lokesh
thanks a lot for your explanation.
I understand it now, that caught exceptions would not terminate the program but uncaught would.
I think overdoing creates more confusion.. I am realising this, day by day getting more
I agree. Here's the link:
subject: MindQ Q31
It's not a secret anymore!