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

 
 

SCJP Module-6 Question-8
Posted on: July 14, 2010 at 12:00 AM
The program given below will test your knowledge of exception handling in Java and helps you for better understanding of Java programs.

Given below the sample code :

public class section68 {
public static void main(String[] args) {
for (int a= 0;a < 10; ++a) {
try {
if (a % 3 == 0)
throw new Exception("Exception1");
try {
if (a % 3 == 1)
throw new Exception("Exception2");
System.out.println(a);
} catch (Exception inside) {
a*= 2;
} finally {
++a;
}
} catch (Exception outside) {
a += 3;
} finally {
++a;
}
}
}
}

What is the output of the above code :

1. Compile error

2.. 0 1 2 3 .....10

3.  4  7

4.  5  8

Answer :

(4)

 

Related Tags for SCJP Module-6 Question-8:


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.