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


Share on Google+Share on Google+
SCJP Module-6 Question-1
Posted on: July 12, 2010 at 12:00 AM
The program given below will test your understanding of Float primitive data types and functions in Java program.

Given below the sample code :

public class SuperClass {
public static void main(String[] args) {


public static boolean stringConvert(String s) {

float factor = 0;
try {
factor = Float.valueOf(s).floatValue();
return true;
} catch (NumberFormatException e) {
System.out.println("Exception in number formatting " + s);
factor = Float.NaN;
} finally {
return false;


Find the output of the following code ?

1. true   Finally

2.  true   Exception in number formatting 0.3A  Finally

3. true Finally False

4. Prints : "Finally"  and give error message.

Answer :


Explanation :

Because the number "0.3A" is not a valid number and also error in converting null to string.



Related Tags for SCJP Module-6 Question-1:

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

Recommend the tutorial

Advertisements Advertisements