aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes got struck with a question. please help me friends. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "got struck with a question. please help me friends." Watch "got struck with a question. please help me friends." New topic
Author

got struck with a question. please help me friends.

K Vidhyakar
Ranch Hand

Joined: Jul 10, 2005
Posts: 68
Which statement is true?
A. catch(X x) can catch subclasses of X.
B. The Error class is a RuntimeException.
C. Any statement that can throw an Error must be enclosed in a try block.
D. Any statement that can throw an Exception must be enclosed in a try block.
E. Any statement that can throw a RuntimeException must be enclosed in a try
block.

here optian A and D seems to be the correct ans. but i cant figure out the one which is right.
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

"vidhyakar vidhyakar,"

Please revise your display name to meet the JavaRanch Naming Policy. You've been asked twice before in previous posts -- and we take this policy seriously. You can edit your name here.

Thank you for your prompt attention!

Now, as to the question...

D. Any statement that can throw an Exception must be enclosed in a try block.

Consider that an unchecked RuntimeException is an Exception, so D is false. Furthermore, even a statement that throws a checked Exception does not need to be in a try block if its enclosing method declares the Exception.


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Sandeep Singh Kunwar
Ranch Hand

Joined: Feb 27, 2006
Posts: 52
D. Any statement that can throw an Exception must be enclosed in a try block.

This can not be right as:


without using try-catch it compiles fine!! as its throwing Exception while method defination block


OfCourse Learner...<br />SCJP 5, SCWCD1.4<br />Blogs: <a href="http://sandeepkunwar.blogspot.com" target="_blank" rel="nofollow">http://sandeepkunwar.blogspot.com</a>
 
jQuery in Action, 2nd edition
 
subject: got struck with a question. please help me friends.