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

 
 

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

 

Advertisement

Related Tags for SCJP Module-6 Question-8:


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 14, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com