195k views
0 votes
If a method writes to a file it should start out like (fill out the blank, what should you write after the parameters in the method header?): accessor returnValue methodName ( parameters ) __________________

1 Answer

2 votes

Answer:

accessor returnValue methodName ( parameters ) throws IOException;

Step-by-step explanation:

If a method writes to a file then it may potentially encounter Input-Output related exception during the execution. In order to handle this scenario the function signature should include the throws clause. So the method signature should be as follows:

accessor returnValue methodName ( parameters ) throws IOException;

For example, if the method is called writeToFile , its signature can be of the form:

public void writeToFile(String data) throws IOException;

User Simeon Nedkov
by
5.1k points