Complete the code to declare that the method throws an exception.
public void readFile() [1] IOException {
// code to read file
}The keyword throws declares that a method may throw an exception.
Complete the code to propagate the exception from methodB to methodA.
public void methodA() [1] Exception { methodB(); } public void methodB() [1] Exception { throw new Exception("Error"); }
Both methods must declare throws Exception to propagate the exception.
Fix the error in the code by completing the method signature to propagate the exception.
public void process() [1] IOException { FileReader file = new FileReader("file.txt"); }
The method must declare throws IOException because FileReader constructor throws IOException.
Fill both blanks to propagate the exception from methodC to methodD.
public void methodD() [1] Exception { methodC(); } public void methodC() [2] Exception { throw new Exception("Failure"); }
Both methods must declare throws Exception to propagate the exception properly.
Fill all three blanks to propagate exceptions correctly in nested method calls.
public void start() [1] IOException { execute(); } public void execute() [2] IOException { read(); } public void read() [3] IOException { throw new IOException("Read error"); }
All methods must declare throws IOException to propagate the checked exception properly.