MCQs
Operator ++ has higher precedence than multiplication operator, *, x is incremented to 9 than
multiplied with 3 giving 27.
output:
$ javac operators.java
$ java operators
27 9
Unary not operator, ~, inverts all of the bits of its operand. 42 in
binary is 00101010 in using ~
operator on var1 and assigning it to var2
we get inverted value of 42 i:e 11010101 which is -43
in decimal.
output:
$ javac bitwise_operator.java
$ java bitwise_operator
42 -43
Operator ++ has the highest precedence than / , * and +. var2 is
incremented to 7 and then used
in expression, var3 = 7 * 5 / 7 + 7,
gives 12.
output:
$ javac operators.java
$ java operators
12
None
output:
$ javac increment.java
$ java increment
1.5 1
Division operator, /, has equal precedence as of multiplication
operator. In expression involving
multiplication and division evaluation
of expression will begin from right side when no brackets
are used.
The right shift operator automatically fills the higher order bit with
its previous contents each time
a shift occurs. This also preserves the
sign of the value.
This is an example of a nested ternary operator. The second evaluation (x < 22) is true,
so the "tiny" value is assigned to sup.
None.
None.
None.