• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

which of the statements are true...

 
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A. catch(X x) can catch subclasses of X.
B. Any statement that can throw an Exception must be enclosed in a try block.

I guess Statement B is true..if not why..

Regards
 
Ranch Hand
Posts: 2412
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, RuntimeException, Error, and their subclasses are unchecked exceptions. Code that may throw them is not required to be in a try block nor is the exception required to be listed in the throws clause of the method containing the code.
 
Ranch Hand
Posts: 809
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Second part is same as your previous thread throw where i gave its explanation.
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Supriya Nimakuri:
A. catch(X x) can catch subclasses of X.
B. Any statement that can throw an Exception must be enclosed in a try block.

I guess Statement B is true..if not why..

Regards



B. No, because the method inside which the statement exists can propagate the exception up via method's throws clause without enclosing the statement in try-catch block.
 
reply
    Bookmark Topic Watch Topic
  • New Topic