Here are some of the key points from each section in this chapter.
q | Relational operators always result in a boolean value (true or false). | ||||
q | There are six relational operators: >, >=, <, <= , ==, and !=. The last two ( == and ! = ) are sometimes referred to as equality operators. | ||||
q | When comparing characters, Java uses the Unicode value of the character as the numerical value. | ||||
q | Equality operators
| ||||
q | When comparing reference variables, == returns true only if both references refer to the same object. |
q | instanceof is for reference variables only, and checks for whether the object is of a particular type. |
q | The instanceof operator can be used only to test objects (or null) against class types that are in the same class hierarchy. |
q | For interfaces, an object passes the instanceof test if any of its superclasses implement the interface on the right side of the instanceof operator. |
q | There are four primary math operators: add, subtract, multiply, and divide. |
q | The remainder operator (%), returns the remainder of a division. |
q | Expressions are evaluated from left to right, unless you add parentheses, or unless some operators in the expression have higher precedence than others. |
q | The *, /, and % operators have higher precedence than + and -. |
q | If either operand is a string, the + operator concatenates the operands. |
q | If both operands are numeric, the + operator adds the operands. |
q | Prefix operators (++ and --) run before the value is used in the expression. |
q | Postfix operators ( + + and --) run after the value is used in the expression. |
q | In any expression, both operands are fully evaluated before the operator is applied. |
q | Variables marked final cannot be incremented or decremented. |
q | Returns one of two values based on whether a boolean expression is true or false.
|
q | The exam covers six "logical" operators: &, |, ^, !, &&, and | |. |
q | Logical operators work with two expressions (except for !) that must resolve to boolean values. |
q | The && and & operators return true only if both operands are true. |
q | The | | and | operators return true if either or both operands are true. |
q | The && and | | operators are known as short-circuit operators. |
q | The && operator does not evaluate the right operand if the left operand is false. |
q | The | | does not evaluate the right operand if the left operand is true. |
q | The & and | operators always evaluate both operands. |
q | The ^ operator (called the "logical XOR"), returns true if exactly one operand is true. |
q | The ! operator (called the "inversion" operator), returns the opposite value of the boolean operand it precedes. |