
Primitive data types:
There are four primitive data types in JAVA.
Interger - byte, short, int, long
Real Number - float, double
Character - char
Boolean - boolean
Write a program to print by default value of all the primitives..
1234567891011121314151617181920212223242526class Type
{
byte a;
short b;
int c;
long d;
float e;
double f;
char g;
boolean h;
public static void main(String args[])
{
Type t1 = new Type();
Syste.out.println("byte default value is "+t1.a);
Syste.out.println("short default value is "+t1.b);
Syste.out.println("int default value is "+t1.c);
Syste.out.println("long default value is "+t1.d);
Syste.out.println("float default value is "+t1.e);
Syste.out.println("double default value is "+t1.f);
Syste.out.println("char default value is "+t1.g);
Syste.out.println("boolean default value is "+t1.h);
}
}
Post A Comment: