This Q is from Khalid Mugal, Pg no.-72, qno.-3.11
Accorind to me the ans is only (f),but according to book it is both (b) and (f) . Pls Explain.
The Q is :-
What would be printed during execution of the following program?
public class MyClass
{
public static void main(
String args)
{
test(1<<32, "1<<32");
test(1<<31, "1<<31");
test(1<<30, "1<<30");
test(1, "1");
test(0, "0");
test(-1, "-1");
}
public static void test(int i,String exp)
{
if( (i >> 1) != (i >>> 1) )
System.out.println(exp);
}
}
Select all valid answers.
(a)"1<<32"
(b)"1<<31"
(c)"1<<30"
(d)"1"
(e)"0"
(f)"-1"