Method x1() has code that calls method x2(). Method x2() has the following header.

public int x2() throws IOException

Which of the following statements is true?

1) Method x2(), in addition to the throws declaration, is required to also handle the exception.
2) Method x1() is not required to do anything since method x2() already declares that it throws IOException.
3) Method x1() must either catch IOException or declare that it, too, throws IOException or a superclass of IOException.
4) If an IOException is generated in the code of method x2(), the exception will be passed back to the caller as an int value.

I believe it is 3.

Respuesta :

Method x1() must either catch IOException or declare that it, too, throws IOException or a superclass of IOException.

Answer: Option 3.

Explanation:

IOException is a special case which developers use in the code to toss a disappointment in Input and Output activities. It is a checked exemption. The software engineer needs to subclass the IOException and should toss the IOException subclass dependent on the specific circumstance.

It can toss an IOException when the either the stream itself is adulterated or some mistake happened during perusing the information for example Security Exceptions, Permission Denied and so on as well as a lot of Exceptions which are gotten from IOException .