What will be the output of the given Java float related code snippet?

 

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) /* Line 9 */
{
    System.out.println("bad number"); /* Line 11 */
}


The answer is : 9

 


Related #tags:     #java     #core-java    

Related questions




Looking for change? Click below to prepare for technical interview.


Technical Interview Questions