Operators_SUMMARY Flashcards

1
Q

What is the Operators Precedence Table?

A

<>

  1. Unary
  2. Arithmetic
  3. Shift Bitwise
  4. Relational
  5. Comparisson
  6. Logical
  7. Ternary
  8. Assignment
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

📝️What are the Unary Operators, It’s precedence and PITFALL case(s)?

A
Post-increment/Post-decrement--++
\++--Pre-increment/decrement
\+ Unary plus 
- Unary minus
~ Bitwise complement
! Logical Complement Operator
(type) Casting operator

🧠️🤯️⚠️📣️ If a post-prefix operator is used in both sides of a assignment expression, the variable won’t be incremented.

🧠️🤯️⚠️📣️ Bitwise complement = - (N+1)

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

📝️ What is a Binary operator, it’s SYNTAX and PITFALL case(s)?

A

A binary operator is an operator that operates on two operands and manipulates them to return a result.

⚠️📣️ SYNTAX => oprnd1 BINARYOPERATOR oprnd2

⚠️📣️ Numeric Promotion
⚠️📣️ FloorVAlue

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

📝️ What are the Arithmetic operators, it’s precedence and PITFALL case(s)?

A

*, /, %, +, -

🧠️🤯️⚠️📣️ Arithmetic Operators lead to NUMERIC PROMOTION Type

o When applying an arithmetic operator ( +|-||/|% ) the result type promotes to int **
o If either operand is double|float|long type, the result is converted to double|float|long

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

🧠️🤯️⚠️📣️ What does Numeric promotion means?

A

o When applying an arithmetic operator ( +|-||/|% ) the result type promotes to int **

o If either operand is double|float|long type, the result is converted to double|float|long

⚠️📣️ Compound Assignment converts type automatically to required assignment type

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

📝️ What is the arithmetic operator that may be applied to String values?

A

Only the addition operators + and +=, which results in String concatenation.

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

📝️ What are the Relational Operators and it’s PITFALL case(s)?

A

Operators which compare two expressions and return a boolean value.
>, >=,

🧠️🤯️⚠️📣️ instanceof PITFALLS:
✅ If null is used on the left side of the instanceof operator it returns FALSE
❌ If null is used on the right side of the instanceof operator ❌The code won’t compile❌
❌ If right-side type cannot possibly hold left-type ❌The code won’t compile❌

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

What are the Comparisson Operators and it’s PITFALL case(s)?

A

==, !=

🧠️🤯️⚠️📣️ Comparison Operators PITFALLS
⚠️ There is a semantical difference between:
-> Objects are equivalent
-> Objects are the same
🤯️ There is no such distinction for primitive types
🤯️ When comparing operands should be from the same type

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

What are the Logical Operators (Bitwise + shortCircuit) and it’s PITFALL case(s)?

A

& Only TRUE if both operands are true
| Only FALSE if both operands are false
^ Only TRUE if both operands are different

SHORT-CIRCUIT: &&, ||
-> Second operand gets evaluated only if necessary

🧠️🤯️⚠️📣️ Logical Operators PITFALLS?
❌ Whatch out when the Logical Complement is being used.
❌ Don’t confuse Bitwise OR with short-circuit OR
⚠️ XOR (Exclusive OR) true ✅^❌ or ❌^✅

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

What is the Ternary Operator and its PITFALL case(s)?

A

? :

🧠️🤯️⚠️📣️ Ternary Operator PITFALLS?
⚠️ When having composed ternary operators whathout it’s balanced. -> Meaning each ‘?’ operator has its counterpart ‘:’
🧠️🤯️⚠️📣️ When assigning the result of a ternary operation expression results type should match

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

What are the Assignment Operators, its Precedence and PITFALL case(s)?

A

=, +=, -=, *=, /=

🧠️🤯️⚠️📣️ Compound assignment can’t be used at inline declarations

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