InterviewSolution
Saved Bookmarks
| 1. |
Primitive types in Java |
||||||||||||||||||||||||||||||||||||
|
Answer» The primitive data types in JAVA are BOOLEAN, byte, char, short, int, long, float and double. These data types have no special capabilities and are only single values. A table that demonstrates all the primitive types in Java is as follows:
A program that demonstrates all the primitive types in Java is given as follows: public class Demo { public static void main(String []args) { boolean var1 = true; byte var2 = 127; char var3 = 'A'; short var4 = -2000; int var5 = 5000; long var6 = 10000; float var7 = 75.8756f; double var8 = 28.84642387; System.out.println("boolean: " + var1); System.out.println("byte: " + var2); System.out.println("char: " + var3); System.out.println("short: " + var4); System.out.println("int: " + var5); System.out.println("long: " + var6); System.out.println("float: " + var7); System.out.println("double: " + var8); } }The output of the above program is as follows: boolean: true byte: 127 char: A short: -2000 int: 5000 long: 10000 float: 75.8756 double: 28.84642387 |
|||||||||||||||||||||||||||||||||||||