Home Tutorial Java Scjp Part6 SCJP Module-6 Question-5

 
 

SCJP Module-6 Question-5
Posted on: July 14, 2010 at 12:00 AM
The program given below will test your understanding about the Exception handling and helps for the preparation of SCJP exams.

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.

Answer :

(4)

Related Tags for SCJP Module-6 Question-5:


Ask Questions?

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.