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

 
 

Share on Google+Share on Google+
SCJP Module-2 Question-15
Posted on: July 8, 2010 at 12:00 AM
Advertisement
The program given below checks the your understating of core java program and also prepare you for SCJP examination

Find the Output of the following code :

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

Find the Output of the above given code :

1. 5  8

2. 5

3. 8

4. compile error

Answer :

  5

  8 

Advertisement

Related Tags for SCJP Module-2 Question-15:


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