This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

on exception

 
velan vel
Ranch Hand
Posts: 137
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hai
here how many statements are 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..

by
velan vel
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Only A is true. An instance of a subclass of X is also an instance of X.

B is false (see API). C is false because Errors are unchecked. D and E are both false because a RuntimeException is an unchecked Exception.

(For C, D, and E, even if these were checked, the statements would still be false. A "throws" declaration could be used in lieu of a try block.)
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic