Chapter 4 - Operators Flashcards

1
Q

Relational operators

A

always result in a boolean value (true or false)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

There are 6 relational operators

A
>
>=
<
<= 
==  (Equality Operator)
!=   (Equality Operator)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Equality Operators

A

There are two: == and !=
4 things can be tested:
numbers, characters, booleans and reference variables

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

When comparing characters

A

Java uses Unicode value of character as the numeric value

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

instanceof operator

A

is for reference variables only, and checks if an object is of a particular type

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

instanceof operator

A

can be used only to test Objects (or null) against class types that are of the same hierarchy

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

for interfaces

A

an object passes the instanceof test if any of its superclasses implement the interface on the right side of the instanceof operator

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

There are 4 primary math operators

A

add, subtract, multiply and divide

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

The remainder operator (%)

A

returns the remainder of a division

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Expressions are evaluated from left to right

A

unless you add parenthesis, or unless some operators have higher precedence

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

*,/, and %

A

operators have higher precedence than + and -

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

If either operand is a string

A

the + operator concatenates the operands

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

If both operands are numeric (in string concatenations)

A

the + operator adds the operands

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Prefix operators ++ and – run

A

before the value is used in the expression

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Postfix operators ++ and – run

A

after the value is used in the expression

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

In any expression

A

both operands are fully evaluated before the operator is applied

17
Q

Variables marked final

A

cannot be incremented or decremented

18
Q

Ternary/Conditional operators returns

A

one of two values based on whether boolean expression is true or false
returns the value after the ? if expression is true
returns the value after the : if expression is false

19
Q

The exam covers 6 ternary operators

A

&, |, ^, !, &&, and ||

20
Q

Logical operators work with two expressions

A

except for (!) that must resolve to boolean values

21
Q

The && and & operators

A

return true only if BOTH operands are true

22
Q

The || and | operators

A

returns true if EITHER or BOTH operands are true

23
Q

The && and ||

A

are known as SHORT CIRCUIT operators

24
Q

The && operand does not evaluate the right operand

A

if the left operand is false

25
Q

The || operand does not evaluate the right operand

A

if the left operand is true

26
Q

The & and | operators

A

always evaluate both operands

27
Q

The ^ operator (called the logical XOR)

A

returns true if exactly one operand is true

28
Q

The ! operator (called the inversion operator)

A

returns the opposite value of the boolean operand it precedes