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
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...
{
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