What is the default value of float and double datatype in Java?

Its my interview question anyone know the correct answer?


Recommended Answers

All 3 Replies

If you really wish to find out then declare a float and a double. Then print them to the screen.


public class Test{

    private float myFloat;
    private double myDouble;

    public static void main(String[] args)
        System.out.println("Float: " + myFloat);
        System.out.println("Double: " + myDouble);

ObSys: if you do feel the need to hand out code, at least make it code that will compile.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.