Write a Program to declare a double variable doubleValand initialize it with the value of 2^16. Declare a shortvariable shortVal and store the value of doubleVal in it. You have to print the value of shortVal.
Answers & Comments
nitish8089
Public class Program { public static void main(String[] args) { double doubleValand=Math.pow(2, 16); // double variable value:
short shortVal=(short)doubleValand; // typecasting double value to short:
System.out.println(shortVal); // print the short value::::
Answers & Comments
{
public static void main(String[] args) {
double doubleValand=Math.pow(2, 16);
// double variable value:
short shortVal=(short)doubleValand;
// typecasting double value to short:
System.out.println(shortVal);
// print the short value::::
// output:: 0
}
}
see out screenshot...