SCJP Module-6 Question-2


 

SCJP Module-6 Question-2

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

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 .

Ads