Computer Applications

What is the output of this program ?

class Output
{
    public static void main(String args[]) 
    { 
        Integer i = new Integer(514);
        float x = i.floatValue(); 
        System.out.print(x);
    }
}
  1. 0
  2. 1
  3. 257
  4. 514.0

Java Library Classes

8 Likes

Answer

514.0

Reason — The float data type stores decimal/floating point numbers. Thus, Integer object 514 will be converted and stored as float value 514.0.

Answered By

5 Likes


Related Questions