Page 1 of 1

About Question enthuware.ocajp.i.v7.2.839 :

Posted: Mon Apr 09, 2012 8:23 am
by Matheus
Look at this question:

Code: Select all

How can you fix the following code to make it compile:
class Great {
    public void doStuff() throws FileNotFoundException{
    }    
}

class Amazing extends Great { 
  public void doStuff() throws IOException, IllegalArgumentException{
  }    
}

public class TestClass {
    public static void main(String[] args) throws IOException{
        Great g = new Amazing();
        g.doStuff();
    }
}
It asks for an option that allows the code to compile. The option Change doStuff in Amazing to throw only IllegalArgumentException., is correct in this point of view, but Change doStuff in Great to throw only IOException instead of FileNotFoundException. is also correct.

So this question is a little ambiguous.

Re: About Question enthuware.ocajp.i.v7.2.839 :

Posted: Mon Apr 09, 2012 1:58 pm
by admin
You are right. Both the options should be correct. This has now been fixed.

thank you for the feedback!

Re: About Question enthuware.ocajp.i.v7.2.839 :

Posted: Wed Aug 22, 2012 9:59 am
by Guest
I found another solution to the answer, which is different from the suggested answer.

Pick these options:
-Change doStuff in Amazing to throw only IOException.
-Change doStuff in Great to throw only IOException instead of FileNotFoundException.

I guess this will work.

Re: About Question enthuware.ocajp.i.v7.2.839 :

Posted: Thu Aug 23, 2012 7:59 am
by admin
You are right but each option is independent of other options. A statement "Assume that changes suggested in a option are to be applied independent of other options." has now been added to avoid this confusion.

thank you for your feedback!