• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/12

Click to flip

Use LEFT and RIGHT arrow keys to navigate between flashcards;

Use UP and DOWN arrow keys to flip the card;

H to show hint;

A reads text to speech;

12 Cards in this Set

  • Front
  • Back

Chapter 4.


Relational Operators:



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.

Relational Operators:



4. When comparing characters, Java uses the Unicode value of the character as the numerical value.

5. When comparing reference variables, == (double equals) returns true only if both references refer to the same object.

Equality operator:



- There are two equality operators:



1. == (double equal).


2. not equal (!=).


- Four types of things can be tested:



1. numbers,


2. characters,


3. booleans,


4. reference variables.

instanceof Operator:



1. 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 Operator:



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 * (multiply), / (division), and % (remainder) operators have higher precedence than + and - (subtract).

String Concatenation Operator:

- If either operand is a String, the + operator concatenates the operands.



- If both operands are numeric, the + operator adds the operands.

Increment/Decrement Operator:



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.

Prefix and Posfix operators example:



int j =0


System.out.println (++j);



- j is incremented by 1 and printed.


- so the output is 1.


System.out.println (j++);



- j is printed first and then incremented.


- so the output is 1 again.


Ternary Conditional Operator:



Returns one of two values based on whether a boolean expression is true or false.

- Returns the value after the ? (question mark) if the expression is true.



- Returns the value after the : (colons) if the expression is false.

Logical Operators:



1. The exam covers six "logical" operators: &, |(or), ^(logical xor), !(inversion), &&(double and), ||(double or).



2. Logical operators work with two expressions, except for !(inversion) that must resolve to boolean values.

3. The && (double and) and & operators return true only if both operands are true.



4. The || (double or) and | (or) operators return true if either or both operands are true.



5. The && (double and) and || (double or) operators are known as short-circuit operators.

Logical Operators:



6. The && (double and) operator does not evaluate the right operand if the left operand is false.



7. The || (double or) does not evaluate the right operand if the left operand is true.



8. The & and | (or) operators always evaluate both operands.

9. The ^(logically XOR) operator, returns true if exactly one operand is true.



10. The !(inversion) operator, returns the opposite value of the boolean operand it precedes.

End. Chapter 4

End. Chapter 4