The method shown below, makeJunk generates compile-time error: “unreported exception java.io.IOException; must be caught or declared to be thrown”.

LANGUAGE: Java

CHALLENGE:

The method shown below, makeJunk generates compile-time error:
“unreported exception java.io.IOException; must be caught or declared to be thrown”.
Without changing the behavior (any part of the method body ) and without changing the number of arguments the function takes or its visibility, add the necessary code that will permit this code to compile without error.

Shown:
public void makeJunk(){
new File(“junk”).createNewFile();
}

SOLUTION:

The Bad News: The content you are trying to access is only available to members.

The Good News: You too can be a member, simply Click Here.

Already a member?

Posted in ,