Sunday, February 19, 2017

Write a JAVA program to display default value of all primitive data types of JAVA

class  DefaultValues
{
     byte b;
     short s;
     int i;
     long l;
     float f;
     double d;
     char c;
     boolean bl;
    public static void main(String[] args)
    {
DefaultValues df=new DefaultValues();
        System.out.println("Byte :"+df.b);
        System.out.println("Short :"+df.s);
        System.out.println("Int :"+df.i);
        System.out.println("Long :"+df.l);
        System.out.println("Float :"+df.f);
        System.out.println("Double :"+df.d);
        System.out.println("Char :"+df.c);
        System.out.println("Boolean :"+df.bl);
    }
}
output:
>java DefaultValues
Byte :0
Short :0
Int :0
Long :0
Float :0.0
Double :0.0
Char :
Boolean :false

No comments:

Post a Comment

Write a JAVA program to sort an array of Strings

import java.util.Scanner; public class SortStrings {     public static void main(String[] args)     {         int n;         String t...