Algorithms 1.1 Flashcards
Data Type
Set of values and a set of operations on those values
Four primitive data types in Java
ints, doubles, booleans, chars
identifier
a sequence of letters, digits, _, and $ the first of which is not a digit
variable
names a data-type value
operator (+,-,*,/)
names a data-type operation
literal
source- code representation of a value
expression
a literal, a variable, or a sequence of operations on literals and/or variables that produces a value
Sets of Values on: int double boolean char
int: integers between -2^31 and +2^31 -1 (32 bit two’s complement)
double: double precision real numbers
boolean: true or false
char: characters (16 bit)
Cast
a directive to convert a value of one type into a value of another type. e.g. casting a double to an int truncates toward zero
Additional Primitives
long- 64-bit ints short- 16-bit ints char- 16 bit chars byte-8 bit ints float- 32-bit single precision real numbers
Statements
Fundamental building block of a program. Contain created and manipulated variables, assigned values, and controlled flow of execution
Declarations
Creates the variable and specifies type and name(identifier)
Assignments
Associate data-type val w/ variable
Initialize Declarations
A declaration and assignment put together. Declares and assigns at same time (e.g. int i=1)
Implicit Assignments
Increment operators such as i++ or i /= 2