Compare and use various data types in a java program, declare and use constant and variables and cast and value of one data type to another data type. Write a java program that initialize the following:
"Data Type"
double
short
double
int
"Variable Name"
size
grade
final_grade
final_length
"Value"
125.83d
87
grade
side
Name the class as Data and save the file. Debug syntax and logical errors if there is any in the program. Save the file.
public class Demo {
public static void main(String[]args) {
double size = 125.83d;
short grade = 87;
double final_grade = (double) grade;
int final_size = (int) size;
}
}
Comments
Leave a comment