1. class X { 2. public void printFileContent () { 3. /* code goes here */ 4. throw new IOException () ; 5. } 6. } 7. public class Test{ 8. public static void main(String[] args) { 9. X xobj=newX(); 10. xobj.printFileContent(); 11. } 12. }
public static void main(String[] args) throws Exception {
Replace line 10 with:try { xobj.printFileContent () ;}catch(Exception e) { }catch (IOException e) { }
public void printFileContent () throws IOException {
throw IOException ("Exception raised");
throw new IOException () ;