fork download
  1.  
  2. class DataTypes
  3. {
  4. public static void main(String [] args)
  5. {
  6. //declaration of variables
  7. // integer  takes whole numbers as 32 bit signed values
  8. int rollNumber;
  9. // double stores 64 bit floating point value
  10. double average;
  11. // byte stores 8 bit signed value
  12. byte age;
  13. //float stores 32 bit signed value
  14. float height;
  15. // short stores 16 bit signed value
  16. short classSection;
  17. //char stores 16 bit Unicode character
  18. char grade;
  19. //long stores 64 bit signed value
  20. long totalMarks;
  21. //boolean stores binary value either true or false
  22. boolean passStatus;
  23. //initialization of variables
  24. rollNumber = 56;
  25. average = 23.4;
  26. age = 30;
  27. height = 6.2f;
  28. classSection = 8;
  29. grade = 'A';
  30. totalMarks = 1910;
  31. passStatus = true;
  32. //print variables
  33. System.out.printf("The roll number of student is: %d \n", rollNumber);
  34. System.out.printf("The average of marks is: %f \n", average);
  35. System.out.printf("The age of student is: %d \n", age);
  36. System.out.printf("The height of  student is: %f \n", height);
  37. System.out.printf("The class section of student is: %d \n", classSection);
  38. System.out.printf("The grade of student is: %c \n", grade);
  39. System.out.printf("The total marks os student are %d\n", totalMarks);
  40. System.out.printf("The pass status of students is : %b\n", passStatus);
  41. }
  42. }
Success #stdin #stdout 0.06s 28132KB
stdin
Standard input is empty
stdout
The roll number of student is: 56 
The average of marks is: 23.400000 
The age of student is: 30 
The height of  student is: 6.200000 
The class section of student is: 8 
The grade of student is: A 
The total marks os student are 1910
The pass status of students is : true