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

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();
}

This content requires that you purchase additional access. The price is $2.99 or free for our Make Life Easier and 30 Days – Not Recurring members.

Purchase this Content ($2.99) Choose a Membership Level