Computer Science, asked by bhan61, 1 year ago

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

Answered by nitish8089
5
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::::

// output:: 0
}
}

see out screenshot...
Attachments:
Similar questions