Given below the sample code :
1 import java.io.StreamCorruptedException;
2 import java.net.MalformedURLException;
3 public class SuperClass {
4 public static void main(String[] args) {
5 try {
6 throw new MalformedURLException("error in url");
7 throw new StreamCorruptedException("error in file");
8 throw new Exception("erorr");
9 System.out.println("try block ");
10 } catch (MalformedURLException e) {
11 System.out.println("error in URL");
12 } catch (StreamCorruptedException e) {
13 System.out.println("error in file contents");
14 } catch (Exception e) {
15 System.out.println("exception");
16 } finally {
17 System.out.println("in finally block");
18 }
19 System.out.println("success");
20 }}
How can we correct the above code :
1. No error in this code.
2. Remove line number 7,8 & 9.
3. Remove Catch block at line 12.
4 Remove line number 7,8 & 9. and Remove Catch block at line 12.
(4)
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.