Share on Google+Share on Google+

SCJP Module-6 Question-2

Advertisement
The given program below will test your knowledge on Exception in Java programing language.

Given below the sample code :

1.  class SuperClass{

2.  public void Function(Ingredient[] list) throws XXX

3.  {

    //body of the Function

N.  } }

The code above throws two exceptions ' ArrayIndexOfBoundException ' ,  ' NullPointerException '.Which given below statement can replace  line number 3 ?

1. public void Function(Ingredient[] list) throws BaseException

2. public void Function(Ingredient[] list) throws ArrayIndexOfBoundException, NullPointerException

3. public void Function(Ingredient[] list) may throw NullPointerException 

4. public void Function(Ingredient[] list)

Answer :

(1) &(2)

Explanation :

BaseException is more general than ArrayIndexOfBoundException or NullPointerException .

Advertisements

Posted on: July 12, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.