Ch2. Data Types (zybooks) Flashcards Preview

Java 1 > Ch2. Data Types (zybooks) > Flashcards

Flashcards in Ch2. Data Types (zybooks) Deck (25)
Loading flashcards...

what is a variable ?

variable= named item that is used to hold a value.


assignment statement?

assignment statement: is when a variable is assigned a value. this is done through a statement.


what is the format of an assignment? hint: statements and variables

the left side of a statement assignment must be a variable while the right side can be an expression. so...
x = (y+5) X is the variable while (y+5) is the expression.


what does
mean in programming ? how does it work

not equals but instead equals is used to assign a value from the right side to a left side variable.
so... x = 5 means x is assigned 5.


what is an incrementing variable and how does it work.

increment variable: when a variable is assigned itself plus one. for example: x = x + 1


variable declaration?

statement that declares a new variable -type and name.


what is an assignment statement?

assignment statement:


what is an assignment statement?

assignment statement:
assigns a variable (left side of = ) with the value to the right of =



expression : a number, variable name or calculation


what does 'int' stand for in code?

int = integer or a number.
it tells the memory to allocate a space for the following object. this object holds a number/integer


can int variables (integer) hold a negative value?

yes, integer values can hold a negative value.


what is a reserve word or keyword?

reserve word/ keyword: a word that is part of the language (int, sort, double,) these words can not be used as an identifier.


how is an _ identified when used in an identifier?

_ is treated as a letter and can be the 1st "letter" in the identifier name.


are spaces allowed in an identifier name?

no, but _ can be used instead.


can an expression be a literal?

expression: evaluates to a value. a literal is a specific value. YES, an expression can be a series of operators (+ - ) with literals or variables or it can just be one literal.


can two - - operators that are negative be next to one another?

- - Yes, seen as one a negative and a negation (negative of the following value)


Precedence rules?

Precedence rules: how math symbols are used in a problem. order of operations..
() first,
-x negative numbers evaluated before multiplication
...use () often to make expressions clear and oreder of operations.


compound operators?

when an operator is compounded for instance: numBalls = numBalls + 1
compounded into:
numBalls += 1


are commands allowed in interger literals and if so how are they used?

no. integer intervals can not use commas.


variable declared with ;double; means what?

is used to store a floating point number which is when a number has a decimal point within it


what is a flouting point litera;?

floating point literal is a number that has a portion that is a fraction and is marked using decimal point with leading zero.


how to do scientific notation for floating point literal?

the letter e is used to represent exponent. so 6.02 x 10^23 would be written as: 6.02e23


what is the name of a variable that cannot change?

constant variable
if a variable is preceded with final variable then the variables value can not change after that statement.


what is a good practicce with writing code when writing a constant variable? what format?

all uppercase letters and word have _ between them.


Modulo operator?

Modulo operator = % when division occurs then this symbol tells what the remainer would be.
example: 23 % 10 = 3
see remainder of 3