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

 
 

Share on Google+Share on Google+
SCJP Module-2 Question-16
Posted on: July 8, 2010 at 12:00 AM
Advertisement
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)

 

 

Advertisement

Related Tags for SCJP Module-2 Question-16:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: July 8, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com