wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Doubt in Error/AssertionError Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Doubt in Error/AssertionError " Watch "Doubt in Error/AssertionError " New topic
Author

Doubt in Error/AssertionError

Gitesh Ramchandani
Ranch Hand

Joined: Feb 28, 2007
Posts: 274
For the following code:



What is the result?
A. end
B. Compilation fails.
C. exception end
D. exception test end
E. A Throwable is thrown by main.
F. An Exception is thrown by main.

Answer: E

output is:


Doubt: According to the answer, option E, I don't see ant Throwable thrown by main(). Is the option E wrong? Please help
Deepak Jain
Ranch Hand

Joined: Aug 05, 2006
Posts: 637
AssertionError extends Error that extends Throwable.
So when AssertionError is thrown by main can also be said as
Error is thrown by main or
Throwable is thrown by main.
Hope that clears.


SCJP, SCWCD, SCBCD
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

Gitesh, when you copy a question from a book or mock exam, you need to quote your sources.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Sunny Jain
Ranch Hand

Joined: Jul 23, 2007
Posts: 433

Hi,
Do Remember the following hirerachy :



or you can say that
Object ----> Throwable ----> Error

So if an instance of type Error is thrown then throwable can catch that, but
Exception can not.


Thanks and Regards,
SCJP 1.5 (90%), SCWCD 1.5 (85%), The Jovial Java, java.util.concurrent tutorial
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Doubt in Error/AssertionError
 
Similar Threads
Q on Exception Handling
Question from mock site
Exception Doubt
About Exception and Throwable
Exception output