Simple program that demonstrates the fundamental concept of variable declarations and assignments. It consists of a `main` method, which is the entry point for Java programs, and within this method, three different variables of distinct data types are declared, assigned values, and then printed to the console.
Firstly, an integer variable `num` is declared and assigned the value 45. This illustrates the declaration and initialization of an integer variable in Java. Subsequently, the value of `num` is printed to the console, resulting in the output of "45."
Next, a double precision floating-point variable `val` is declared and initialized with the value 7.89. This demonstrates how to work with floating-point numbers in Java. The value of `val` is then printed, producing "7.89" as the output.
Lastly, a character variable `ch` is declared and assigned the character 'J'. This showcases the declaration of a character variable in Java, and the character 'J' is printed to the console as the output.
Post a Comment