004 - Operators Flashcards
Which operator is evaluated from right to left?
The assignment operator
Which is the order of precedence for operators?
postfix unary multiplicative additive shift relational equality bitwise AND bitwise exclusive OR bitwise inclusive OR logical AND logical OR ternary assignment
Which are the postfix operators?
expr++
expr–
Which are the unary operators?
\++expr --expr \+expr -expr ~ !
Which are the
multiplicative operators?
*
/
%
Which are the additive operators?
+
-
Which are the shift operators?
>
|»_space;>
Which is the type comparison operators?
instanceof
Which are the equality and relational operators?
==
!=
>
>=
Which are the bitwise operators?
Bitwise inclusive AND &
bitwise exclusive OR ^
bitwise inclusive OR |
Which are the logical operators?
logical AND &&
logical OR ||
Which are the ternary operators?
?
:
Which are the assignment operators?
= \+= -= *= /= %= &= ^= |= >= >>>=
What is concatenation and how is it used?
Joining two strings together
By using the operator +
What can a unary operator do?
operations such as
incrementing/decrementing a value by one,
negating an expression,
or inverting the value of a boolean.
Where can the increment and decrement operators be used?
As prefix or postfix
What is the difference between a prefix and a postfix increment/decrement operator?
the prefix version (++result) evaluates to the incremented value,
the postfix version (result++) evaluates to the original value.
What is the difference between = and ==?
= assignment operator
== equality operator
What is short-circuiting behavior?
the second operand is evaluated only if needed.
It is used with conditional-AND and conditional-OR operators (&& and ||)
What is ?: and how is it used?
The ternary operator or if-then-else statement
If someCondition is true, assign the value of value1 to result. Otherwise, assign the value of value2 to result.”
When is useful to use the ? : operator?
if it makes the code more readable;
E.g., when the expressions are compact and without side-effects (such as assignments).
In which direction are operators evaluated?
From left to right, except for the assignment operator
Which operator can be used to test if an object is an instance of a class, of a subclass, or of a class that implements a particular interface.
instanceof
What is null an instance of?
Nothing