This book is now obsolete Please use CSAwesome instead.
3.13. Variables - Summary¶
In this chapter you learned about the three primitive types on the exam: int
, double
, and boolean
. You also learned how to declare (name) and change the value of variables. You learned about operators, casting, and integer constants for the min and max integer values. You also learned how to create a random number.
3.13.1. Concept Summary¶
Boolean - An expression that is either
true
orfalse
.Camel Case - One way to create a variable name by appending several words together and uppercasing the first letter of each word after the first word (
myScore
).Casting a Variable - Changing the type of a variable using (type) name.
Double - A type in Java that is used to represent decimal values like -2.5 and 323.203.
Declare a Variable - Specifying the type and name for a variable. This sets aside memory for a variable of that type and associates the name with that memory location.
Initializing a Variable - The first time you set the value of a variable.
Integer - A whole number like -32 or 6323.
Modulus - The
%
operator which returns the remainder from one number divide by another.Operator - Common mathematical symbols such as
+
for addition and*
for multiplication.Random Number - A random number picked from a range of numbers. Used in games to make the game more interesting.
Shortcut Operators - Operators like
x++
which meansx = x + 1
orx *=y
which meansx = x * y
.Variable - A name associated with a memory location in the computer.
3.13.2. Java Keyword Summary¶
boolean - used to declare a variable that can only have the value
true
orfalse
.double - used to declare a variable of type double (a decimal number like 3.25).
false - one possible value for a boolean variable.
int - used to declare a variable of type integer (a whole number like -3 or 235).
static - means that the field or method exists in the object that defines the class.
true - one possible value for a boolean variable.
3.13.3. Practice¶
-
3-13-1: Drag the definition from the left and drop it on the correct concept on the right. Click the "Check Me" button to see if you are correct
Review the summaries above.
- Specifying the type and name for a variable
- declaring a variable
- A whole number
- integer
- A name associated with a memory location.
- variable
- An expression that is either true or false
- Boolean
-
3-13-2: Drag the definition from the left and drop it on the correct concept on the right. Click the "Check Me" button to see if you are correct.
Review the summaries above.
- Setting the value of a variable the first time
- initialize
- An operator that returns the remainder
- modulous
- a type used to represent decimal values
- double
- changing the type of a variable
- casting