File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Que from JQPlus!! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Que from JQPlus!!" Watch "Que from JQPlus!!" New topic

Que from JQPlus!!

Ashok Paulraj
Ranch Hand

Joined: Jul 07, 2003
Posts: 78
Consider the following hierarchy of Exception classes :
+-- 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?


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,

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
Phil Rhodes
Ranch Hand

Joined: Dec 27, 2003
Posts: 65
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.

A+, Network+, SCJP, SCWCD<br />preparing for SCBCD, SCEA, CompTIA I-Net+
I agree. Here's the link:
subject: Que from JQPlus!!
It's not a secret anymore!