• 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

Que from JQPlus!!

 
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Consider the following hierarchy of Exception classes :
Exception
+-- RuntimeException
+-- IndexOutOfBoundsException
+-- ArrayIndexOutOfBoundsException, StringIndexOutOfBoundsException
Which of the following statements are correct for a method that can throw ArrayIndexOutOfBounds as well as StringIndexOutOfBounds Exceptions but does not have try catch blocks to catch the same?

Options

Select 3 correct options.

1) The method calling this method will either have to catch these 2
exceptions or declare them in it's throws clause.


2) It's ok if it declares just 'throws ArrayIndexOutOfBoundsException'


3) It must declare 'throws ArrayIndexOutOfBoundsException,
StringIndexOutOfBoundsException'


4) It's ok if it declares just 'throws IndexOutOfBoundsException'


5) It does not need to declare any throws clause.

The given answers were: 2, 4 & 5.
I selected 1,2 & 4.
clarify the correct answers!!!
~ Shalini
 
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
IndexOutOfBoundsException, ArrayIndexOutOfBoundsException and
StringIndexOutOfBoundsException all inherit from RuntimeException
(indirectly in the case of ArrayIndexOutOfBoundsException and StringIndexOutOfBoundsException). Anything inheriting from
RuntimeException is considered a non-checked exception, and
does not have to be declared to be thrown by a method. However, while
you don't *have* to declare it, you *may* declare it. So in this case,
you could declare either one by itself, neither, or both.
reply
    Bookmark Topic Watch Topic
  • New Topic