Introduction to For Loops Flashcards

1
Q

what is a code block?

A

a code block is the curly brackets {}, this indicates the start and stop of a block of code in Java

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

what is a local variable?

A

a local variable is a variable that is declared within the body of a method directly, outside of any other code blocks such as conditionals or loops.
a variable that can only be used within a specific scope.

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

why use local variables?

A

local variables use less memory
remains the same (other parts of the program can’t change the variable)
reuse variable names

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

what symbols are the arithmetic operators?

A

+,-,*,/,%

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

what is this operator %

A

this is the modulus operator or remainder operator

example 7%5 = 2

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

is order of operations followed in Java

A

yes, order of operations is performed the same as in basic math

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

what is integer division

A

integer division is when the final result will be an integer, any remainder will be lost.

ex.
i = 5/2
i = 2

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

what is a compound assignment operator?

A

a compound assignment operator is when you want to add a number to another number that is already stored in a variable, then assign the result back into the variable.
ex.
int count = 0;
count = count + 10;

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

what are all of the compound assignment operators?

A

+= - adds and assigns
-= - subtracts and assigns
*= - multiple and assigns
/= - divides and assigns
%= - modulo and assigns

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