Home Tutorial Java Scjp Part2 SCJP Module-2 Question-16

 
 

SCJP Module-2 Question-16
Posted on: July 8, 2010 at 12:00 AM
The program given below checks your knowledge of exception handling in Java and. This program also gives some knowledge that how the try block is used in a Java program.

Find the Outputs of the given below code having nested try blocks :

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

Find the Outputs of the given below code having nested try blocks :

1.   4  5

2.  4

3.  5

4 compile error

Answer :

(1)

 

 

Related Tags for SCJP Module-2 Question-16:


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.