Pages

Aug 2, 2012

Operators


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


regards,
Tech Dexters Support Team,
Hyderabad.


for Feedback and Support simply drop a mail in
techdexters{at}gmail.com
Remember to replace the {at} with @ in the email addresses

No comments:

Post a Comment