Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

on exception

 
velan vel
Ranch Hand
Posts: 137
  • 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
  • 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.)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic