What is the output of the given java code?
public class HelloWorld
{
public void ret(int a, int b)
{
double res = Math.pow(a,b);
System.out.println(res);
}
public static void main(String []args)
{
HelloWorld h = new HelloWorld();
int i = (1048576>>8>>3>>4>>3);
int y = 1024>>4>>3;
h.ret(i,y);
}
}
-
25686.0
-
25656.0
-
65556.0
-
65536.0
-
Compilation error
D
Correct answer
Explanation
This is the correct choice. The value of variable i after evaluating the expression (1048576>>8>>3>>4>>3) comes out to be 4 and the value of variable y after evaluating the expression comes out to be 8. Both the values are passed to the function “ret(i,y)” to evaluate ret(4,8). This function finds the 4 raised to power 8 and prints that value on the screen.After evaluating the value comes out to be 65536.0. So this answer is correct.