• 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

exceptions

 
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Exception
+--Runtime Exception
+--IndexOutOfBoundsException
+--ArrayIndexOutOfBoundsException
+--StringIndexOutOfBoundsException
If you had a method X that could throw both array index and string index exceptions. Assuming that X does not have any try-catch statements, which of the following statements are correct?
Could someone explain this to me...
The declaration for X doesn't have to include "thows ArrayIndexOutOfBoundsException, StringIndexOutOfBoundsException"

B.
 
Chicken Farmer ()
Posts: 1932
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
These are RuntimeExceptions, so you don't have to declare throwing the exceptions.
If you had to always either catch or throw those exceptions, your code would be littered with try/catch blocks and throws statements.
Jason

[This message has been edited by jason adam (edited November 06, 2001).]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic