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 the two correct answers.
"1<<32"
"1<<31"
"1<<30"
"1"
"0"
"-1"
3.21
Which of the following are not operators in Java?
Select the two correct answers.
%
<<<
&
%=
>>>
<=
&&=
3.22
Given a variable x of type int (which may contain a negative value), which are correct ways of doubling the value of x , barring any wrapping of out-of-range intermediate values?
Select the four correct answers.
x << 1;
x = x * 2;
x *= 2;
x += x;
x <<= 1;
3.23
Which of the following operators can be used both as an integer bitwise operator and a boolean logical operator?
Select the three correct answers.
^
!
&
~
3.24
Given these declarations, which of the following expressions are valid?