Encoded to a program is stored in memory and can have and be in several types—for example, using a person’s basic information such as name, age, and address.
Data
Describe possible operations on the data and the storage method.
Data Types
Data Types in Java are Classified in 2:
Built into the Java language. These are data that are not objects and have no methods. The Java compiler has detailed instructions on the valid operations this data type supports.
Primitive Data Types
Primitive Data Types that java defines:
Java defines Byte, Short, Int, and Long as _. Since Java does not support unsigned integers, these four (4) are signed, positive, and negative values.
Integer Data Types
Java does not support unsigned integers as these are mostly used to specify the behaviors of the—
High-order bit
defines the sign of an integer value, and Java manages it differently by adding a special “unsigned right shift” operation.
High-order bit
Integer Types:
Default number java knows:
Integer
The smallest integer type that represents a small number. It is used to declare a variable holding a natural number between -128 and 127.
Byte
Byte variables are declared by use of the byte
Byte range:
-128 to +127 signed
An integer is considered _ if its value is between -32768 and 32767. _ data types declare a variable that can hold numbers in that range.
Short
Short Range
-32,768 to +32,767
A _ number can also be initialized as a Short variable instead of a normal decimal integer.
So, the 3001 integer can be written as 0x4A8. 0x is used in Java to represent:
Hexadecimal
This data type can handle larger numbers and is considered the best choice when an integer is needed because when Byte and Short values are used in an expression, they are promoted to _ automatically.
Int
Int Range:
-2,147,483,648 to 2,147,483, 647
This data type holds a number higher than a regular integer. The _ integer is a variable that can hold a very large number. A capital letter ‘L’ is placed right after the value.
Long
also called “real numbers”, and are used when evaluating an expression that needs fractional accuracy such as the computation of square root or a transcendental (sine and cosine)
Floating Point Types
Floating Point Types:
described as a single precision floating point. A real number qualifies as a single precession when it only needs a limited number of bits. Single precision takes half the space of a double precision and is much faster on some processors.
_ are used to represent dollars and cents, so a small letter ‘f’ is placed to the right of the value when initializing the variable.
Float
Floats are used to represent dollars and cents, so a _ is placed to the right of the value when initializing the variable.
small letter ‘f’
A real number qualifies as a _ when it only needs a limited number of bits. _ takes half the space of a double precision and is much faster on some processors.
single precission
_ can be faster than single precision on modern processors that have been optimized for high-speed mathematical calculations. It can handle larger numbers than Float.
Double