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

 
 

Share on Google+Share on Google+
SCJP Module-6 Question-27
Posted on: July 15, 2010 at 12:00 AM
Advertisement
The program given below will check the understanding of finally block of Exception Handling in Java.

Given below the sample code :

 Float pi = new Float(3.14f);
if (pi > 3) {
System.out.print("value of pi is greater than 3");
}
else {
System.out.print("value of pi is less than 3 ");
}
finally {
System.out.println("Now you know pi's value");
}

What will be the output of the following code ?

1. Error in compilation

2. value of pi is greater than 3 Now you know pi's value

3. value of pi is less than 3  Now you know pi's value.

4. Now you know pi's value

Answer

(1)

Explanation

Error in compilation is due to the "finally" clause without "try".

 

Advertisement

Related Tags for SCJP Module-6 Question-27:


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

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com