Multiple choice

What will be the output of the program?

try 
{
    Float f1 = new Float(3.0);
    int x = f1.intValue();
    byte b = f1.byteValue();
    double d = f1.doubleValue();
    System.out.println(x + b + d);
}
catch (NumberFormatException e) 
{
    System.out.println(bad number);
}

  1. 9.0

  2. bad number

  3. compilation fails on line 13

  4. compilation fails on line 14

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

The xxxValue() methods convert any numeric wrapper object's value to any primitive type. When narrowing is necessary, significant bits are dropped and the results are difficult to calculate.