1/43
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai | Chat |
|---|
No analytics yet
Send a link to your students to track their progress
Identifier
A name created by a programmer for an item like a variable, method, or class
What is camel case?
Identifier style where each word is capitalized except the first
ex. numApples
What is underscore seperated?
Identifier style where words are lowercase and separated by an underscore
What is a good practice when it comes to abbreviations in identifiers?
Avoid abbreviations in identifiers except for well-known ones
What is a literal?
A specific value, like 2, 3, 4, “hello”
What is a variable?
A named item which is used to hold a value
What is an operator?
Symbol that performs a built-in calculation
ex. +, -
What is an expression?
Combination of items, like variables, literals, operators, and parentheses, that evaluates to a value
What is a variable declaration?
A statement that declares a new variable, specifying the variable’s name and data type
ex. int userAge;
ex. double tickerCost;
How many times can you declare a variable?
Once
What is assignment?
To assign a variable with a value
What is the assignment operator?
=
What is initializing?
When you assign data to a variable for the first time
Can you initialize and declare a variable at the same time?
Yes!
ex. int avgLifespan = 70;
What is incrementing?
Having the same variable on both sides of an assignment. It will use the value of that variable to do the expression and then replace that variable with the result
ex. if numItems is 5
numItems = numItems + 1;
numItems will now equal 6
Where are expressions commonly?
On the right side of an assignment
What is % ?
Modulo operator to calculate the remainder
explanation- for example 51 % 2 would be 1 since the furthest 2 can get to 51 (by multiplying) is 50. so the remaining value to get to 51 would be 1.
What is an operand?
object to be operated
What is an unary operator?
takes a single operand
ex. a negative number
What is a binary operator?
Takes two operands
ex. y + 50
What is evaluated first, () or unary operators?
Parentheses ()
What is evaluated after unary operators?
*, /, %
What is a compound operator?
A shortcut way to update a variable, like wanting to add, subtract, multiply etc. to a variable that already has a value
ex. numPeople += 10
would add 10 to numPeople
How many bytes and bits does a byte have? What numbers can it store?
1 byte
8 bits
Store whole numbers from -128 to 127
How many bytes and bits does a short data type have?
2 bytes
16 bits
How many bytes and bits does an int have? What numbers can it store?
4 bytes
32 bits
can store + or - 2 billion
How many bytes and bits does a long data type have?
8 bytes
64 bits
What is not allowed in an integer literal?
commas are not allowed in numbers
ex. 1,350 not allowed
What can never be the second operand of / or %? (like on the right side of it) and why?
0 because division by 0 is mathematically undefined
What would happen if 0 was on the right side of / or %?
A run-time error
How many bits and bytes does a float data type have? What numbers can it store?
4 bytes
32 bits
Stores fractional numbers (about 6 to 7 decimal digits
How many bytes and bits does a double data type have? What numbers can it store?
8 bytes
64 bits
can store fractional numbers (stores 15 decimal digits)
What are floating-point numbers?
A real number containing a decimal point that can appear anywhere in the number
ex. 0.1 not .1
ex. 1.0 not 1.
What are floating-point numbers?
a literal referring to a number with a fractional part
ex. can be .14 or 0.14
When are integer variables typically used?
Typically used for values that are counted
ex. 42 cars
When are floating-point variables typically used?
For measurements
ex. 98.6 degrees
What does dividing a nonzero floating-point number by zero result in?
infinity or -infinity
(Note- at least one of the numbers has to be a decimal whether that be the 0 or the nonzero number)
What would dividing a positive floating-point number by zero result in?
infinity
ex. 3.14 / 0.0 = infinity
What would dividing a negative floating-point number by zero result in?
-infinity
ex. (-3.14) / 0 = =infinity
What would dividing 0.0 by 0.0 in a floating point division result in?
NaN (not a number)
0.0 / 0.0 = NaN
or
0.0 / 0 = NaN
What is allocation?
Process of determining a suitable memory location to store data like variables