What is the order of operator precedence?
Post-unary operators expression++, expression–
Pre-unary operators ++expression, –expression
Operator Symbols and examples
Other unary operators +, -, !
Multiplication/Division/Modulus *, /, %
Addition/Subtraction +, -
Shift operators <>,»_space;>
Relational operators , <=, >=, instanceof
Equal to/not equal to ==, !=
Logical operators &, ^, |
Short-circuit logical operators &&, ||
Ternary operators boolean expression ? expression1 : expression2
Assignment operators =, +=, -=, *=, /=, %=, &=, ^=, !=, «=,»_space;=,»_space;>=
What are the rules of primitive numeric promotion?
Numeric Promotion Rules
1. If two values have different data types, Java will automatically promote one of the values
to the larger of the two data types.
Draw the logical true tables for &, |, and ^
Here are some tips to help remember this table:
■ AND is only true if both operands are true.
■ Inclusive OR is only false if both operands are false.
■ Exclusive OR is only true if the operands are different.
Explain the rules for the (short circuit) conditional operators, && and ||
The short-circuit operators are nearly identical to the logical operators,
& and |, respectively, except that the right-hand side of the expression may never be
evaluated if the fi nal result can be determined by the left-hand side of the expression.
Explain instanceof
Will return T or F. Left hand side must be an object, not a primitive. This will not compile: int s =1; Boolean b = s instanceof Number;