Print default value of all primitive data types in Java.

 Write a program to display the default value of all primitive data types in Java.


Source Code : 

  
import java.io.*; // java library import 
// declare class name as  'def'
class def {

    static byte b; 
    static short s;
    static int i; 
    static long l; 
    static float f; 
    static double d;
    static char c;
    static boolean bl;

   public static void main(String[] args)  { 

      System.out.println("Byte:"+b);
      System.out.println("Short :"+s);
      System.out.println("Int :"+i);
      System.out.println("Long :"+l);
      System.out.println("Float :"+f);
      System.out.println("Double :"+d);
      System.out.println("Char :"+c);
      System.out.println("Boolean :"+bl);
      
   }

}

Output : 
Byte:0
Short :0
Int :0
Long :0
Float :0.0
Double :0.0
Char :
Boolean :false

 



JAVA Program output screenshot :






Post a Comment

0 Comments

Close Menu