Declaring and using constants and variable Flashcards
when the value of data item cannot be changed while running a program.
Constant
___ can be refer as literal constant, numeric constant, unnamed constant or simply, hard-coded.
459
a named memory location that can store a value. It can only hold one value but the value it hold can be changed.
Variable
describes the type of data that can be stored, how much memory the item occupies and types of operation that can be perform on the data.
Data type
– is a statement that reserves a named memory location
Variable declaration
A ______ that identifies the type of data that the variable will store
data type
An _____ that is the variable’s name
identifier
begins with lowercase letter and capitalizing subsequent words within the identifier
Camel Casing
An __________ , if you want a variable to contain an initial value
optional assignment operator (=) and assigned value
contains unknown value (garbage value)
Uninitialized variable –
– to declare 2 or more variables of the same type in a single statement, it is separated by a comma.
Multiple variable declaration
the value of the location should not be changed during execution.
Named Constant
All of integer data type are signed
(+ or -)
Declaring integer data type:
- int (variable)
- byte (variable)
- short (variable)
- long (variable)
BOOLEAN DATA TYPE
Only has 2 values (true or false)
use to compare two items.
- also called “comparison operators”
Relational operator –
Two floating-point data types
Two floating-point data types
number contains decimal.
Floating-point –
- float
- double
– data type that can hold values up to 6 or 7 significant accuracy
– data type that can hold values up to 14 or 15 significant accuracy
data type to hold single character.
char
– built-in class that provides the means for storing and manipulating character strings.
String
special characters that begins with a backslash.
Escape Sequence
is used for obtaining the input of the primitive data type.
Scanner –
– retrieved value from an input device.
Token
- Java supports two types of division
Floating-point division
Integer division
Floating-point division
Integer divisiom
– occurs when either or both operands are
floating-point values. Example: 45.0 / 2 = 22.5
– occurs when both operand are integers.
Example: 45 / 2 = 22
is the remainder operator
- it results the remainder of two integers.
Percent sign (%) or Modulo –
is the process of converting one data type to another.
Type conversion –
it automatically converts nonconforming operands to the unifying type. It is also called Promotions.
In implicit conversion
is the type to which all operands in an expression are converted so that they are compatible to each other
Unifying type
is the overriding the unifying type.
Explicit Conversion –
forces the value of one data type to be used as a value of another data type
Type Casting
– is created by placing the desired result type in parenthesis.
Cast Operator