Hi i am rafiq,
What is the default value of float and double datatype in Java? Its my interview questions could anyone tell me the answer please..
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
Hi i am rafiq,
What is the default value of float and double datatype in Java? Its my interview questions could anyone tell me the answer please..
Why not answer the question by writing a test program to print out the default value? Or...another way, do an internet search? One of the top hits for the keywords in your post, one which contains the answer:
Primitive Data Types (The Java™ Tutorials > Learning the Java Language > Language Basics)
Sorry to be blunt, but either way it's problem solving - a rather important trait in the world of programming.
See more at: Data Types Default Valuespublic class DataTypeDefaults { byte byteValue; short shortValue; int intValue; long longValue; float floatValue; double doubleValue; char charValue; boolean booleanValue; String stringValue; public static void main(String args[]) { DataTypeDefaults dtd = new DataTypeDefaults (); System.out.println("byte default value: " + dtd.byteValue); System.out.println("short default value: " + dtd.shortValue); System.out.println("int default value: " + dtd.intValue); System.out.println("long default value: " + dtd.longValue); System.out.println("float default value: " + dtd.floatValue); System.out.println("double default value: " + dtd.doubleValue); System.out.println("char default value: " + dtd.charValue); System.out.println("boolean default value: " + dtd.booleanValue); System.out.println("String default value: " + dtd.stringValue); } }
This isn't my work but I found it on the website above and figured it could help you.