All the posts and topics that contain only an error report will be moved here after the error is corrected. This is to ensure that when users view a question in ETS Viewer, the "Discuss" button will not indicate the presence of a discussion that adds no value to the question.
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.
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.
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.