Expressions
What's the difference between a "statement" and an "expression"?
What are expressions made of?
What do "arithmetic expressions" evaluate to?
What do "boolean expressions" evaluate to?
Arithmetic Expressions
What are the 5 Java arithmetic operators?
1. Addition
2. Subtraction
3. Multiplication
4. Division
Integer Division
Floating Point Division
5. Modulus(mod) / Remainder
What do we mean by operator precedence?
What do we mean by associativity? Is arithmetic "left" or "right" associative?
What about assignment?
What else can we use to force an expression to be evaluated a certain way?
What are some "shortcuts" we can use?
Why is the last statement below illegal? How can we use "casting" to fix it?
double weight = 140.85;
int bobsWeight;
bobsWeight = weight;
How can we use "casting" to force floating point division to occur?
int sum = 4 + 5 + 3 + 10;
double average = sum / 4;
What are some of the handy Math library constants and methods?
Boolean Expressions
What are the 6 Java comparison operators?
1. less than
2. less than or equal to
3. greater than
4. greater than or equal to
5. equal to
6. not equal to
What are the 3 Java logical operators?
1. not
2. and
3. or
Which has higher precedence && or ||?
What is the value of each of the following boolean expressions?
boolean isRaining = true;
boolean isWednesday = false;
boolean haveUmbrella = true;
isRaining && haveUmbrella
isRaining || isWednesday
!isRaining
!(isRaining && !haveUmbrella)
isRaining || isWednesday && !haveUmbrella
How can we use De Morgan's Law to simplify boolean expressions?
! ( isRaining && isWednesday)
! ( isRaining || isWednesday )
!(isRaining && !haveUmbrella)