What will be the output of the following Java code?

class Output
  {
      public static void main(String args[])
      {
      Double i = new Double(257.578123456789);  
          float x = i.floatValue();
          System.out.print(x);
      }
  }

a) 0
b) 257.0
c) 257.57812
d) 257.578123456789

1 thought on “What will be the output of the following Java code?”

  1. c
    Explanation: floatValue() converts the value of wrapper i into float, since float can measure till 5 places after decimal hence 257.57812 is stored in floating point variable x.
    Output:
    $ javac Output.java
    $ java Output
    257.57812

Leave a Comment