What is the difference between the following two:
(double) 5 / 2
(double) (5 / 2)
Only the first one will result in a double.
What is the difference between the following two:
(double) 3.5
Math.round(3.5)
The first one will just drop the decimal.
The second one will actually round upwards.
How would I read this?
false && true || false
&& has higher priority than ||.
False
How would I read this?
true || false
true
How would I read this?
false && false
false
What is De Morgan’s laws?
!(A && B) ≡ (!A) || (!B)
!(A || B) ≡ (!A) && (!B)
What is the fourth letter?
She ate that.
a space
What is a compiler?
Translates an entire code into binary in many steps
What is an interpreter?
Translates code one step or line at a time.
What type of language is Java?
A hybrid language (compiles and then interprets)
What is the variable?
What is the literal?
What is the declaration statement?
What is the assignment statement?
int a;
a = 17;
a
17
int = a;
a = 17;
What must variables start with?
letter
$
underscore
Compile Time error vs. Runtime Error
Primitive vs Reference type
Primitive stores the actual value for a variable
Reference refers to the address of a primitive
What is the difference?
5 / 0
5.0 / 0
Error
Infinity
When does a number truncate?
When a double –> int it loses its decimal places
What is concatenation?
Adding Strings together
Can int be converted to double?
Can double be converted to int?
Yes
No
How do you convert a double to int?
(int) double
(int) 5.6 –> 5
How do you do an enhanced for loop?
// Random Array here
for (class name : array name) {
function that affects each object
}