test2 Flashcards
curly braces or the _____ _____ _____ can control the scope of a vriable
SCOPE INDEX OPERATORS
what is a variable?
a storage location in a computer’s ram memory
a variable has a ____ and a ____ ____ specified
name (identifier, reference, handle) and data type(int,String)
what do we do when we declare a variable
we specify its data type and name
what is the assignment operator
=
When we declare a variable, we’re ______ the name of the variable to a particular memory location address
binding
How must a Java variable identifier must start with
a letter, and underscore or a $ sign
True or false: You cannot start a variable name with a digit such as 3 or 7.
True it causes a compile error
is java case sensitive?
yes
can you use java reserved words or keywords such as public, class or else identifiers?
nope compile error
java names begin with a ____
lower case letter
how is the second word in a variable name written out
with a capital letter, camelBack
true or false. in java our programs statements are always contained inside a class file
true
class names always start with a
capital letter and each new word also starts with a capital letter
variable names start with a \_\_\_\_ case letter class names start with a \_\_\_\_ case letter
lower (camelBack)
upper (title case)
why do we specify the data type when we declare a variable?
tells os how many bytes of memory is needed for that variable and BC program uses data type to interpret the data that is stored
True or false: ASCII and Unicode: first 256 values are identical
true
do primitive data types have methods associated with them?
nope
how many primitive data types are there in java
8
what is mantissa and exponent
mantissa is the first part of an exponent the number that is going to be multiplied by 10 to the exponent. exponent is what it is
is a string an object
yes
what is a method in java
a method is some lines of code that are put in their own code block (inside their own curly braces) and this block is given a method name
T or F: Var keyword only be used when created local variables within a method
True
how are constants declared
with the keyword final along with its data type that it will hold
constants can be declared on one line and initialized later on in another line
true
what is a data literal
a data literal is an actual data value that appears in a program. its the value that is declared
if you divide an integer by another integer does java give you an integer answer?
yes
when dividing an integer literal by another integer java will do what to the decimal portion
truncate
are primitive data types objects?
nope
integer primitive data types
byte(8)m short(16), int (32), long(64)
floating data types
float and double
char is a single word
nope letter
what are the binary operators
+ - * / %
the answer of a modulus division operation is the ______ of value from a regular division operation
REMAINDER
equals we use ___ and not equal is ____
== and !=
by default a numeric literal value is assumed to be ____
positive
increment operator
decrement operator
++
–
True or false: An if structure is a single-selection type of structure because it either selects to carry out, or it ignores, a single action.
True
should you put curly braces around every if block statement, even if there is only 1 statement to execute
yes, good coding style
The logical AND indicates that both conditions must be truein order for the overall if expression to return a value of ____.
true
if either condition is false, or both are false, then the overall if expression evaluates to ____
false
true or false: the only way to get a true result from a logical and operation is for both conditions to be true
True
Why do we use the && and || symbols when & and | seem to do the same thing?
The single ‘&’ AND operator is the ‘bitwise’ operator. It compares the corresponding bits of each operand to determine the overall true or false result. So, it does both comparisons, no matter what the first comparison return
but the && || will stop after reading a false value- saves a few cpu cycles
declaring a variable
defining its type
initializing a variable
specify the value to be stored in the variable
4 rules of naming variables
1 start with letter or underscore
2. can’t use ? or %, spaces
3 variable names are case sensitive
4 you cannot use reserved words such as double or class as names
what are two downsides of using objects such as BigDecimal and BigInteger in calculations?
slow and you have to call in methods called add, subtract and multiply
what is a package and what does it contain
it is a collection of classes with a related purpose
how do you tell in java code that a character should be interpreted as a character literal?
single quotes ‘ ‘