1/14
Flashcards covering data types, variables, type casting, type conversion, and constants in Java programming.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
Primitive Data Types
Predefined data types in Java that specify the size and type of standard values. Includes byte, short, int, long, float, double, char, and boolean. Values are assigned to the stack.
Non-Primitive Data Types
Data types not defined by the programming language but created by the programmer and reference a memory location. Examples include Strings, Arrays, Classes, and Interfaces.
Byte
An 8-bit signed two’s complement integer that stores whole numbers from -128 to 127 and is helpful for saving memory.
Short
A data type greater than byte and less than an integer that stores values ranging from -32,768 to 32,767. The default size is 2 bytes.
Int
A data type that stores whole numbers from -2147483648 to 2147483647 and is generally preferred for numeric values.
Long
A 64-bit two’s complement integer with a value range from -2^63 to 2^63-1.
Float
A data type used to store floating-point numbers with single precision, typically occupying 4 bytes (32 bits) of memory with approximately 7 decimal digits of precision.
Double
A data type used to store floating-point numbers with double precision, typically occupying 8 bytes (64 bits) of memory with approximately 15-16 decimal digits of precision.
Char
Data types that are strings of characters; upper and lower case alphabetic characters are accepted literally.
Boolean
A data type with one of two possible values (true and false) to represent the two truth values of logic and Boolean algebra.
Variables
Containers for storing data values of different types, such as String, int, float, char, and boolean.
Type Casting
Converting a data type into another data type manually by a programmer. It is a narrowing conversion where the destination data type must be smaller than the source data type.
Type Conversion
When a data type is automatically converted into another data type at compile time. It is a widening conversion where the destination data type should not be smaller than the source type.
Constant
A variable whose value cannot be changed, defined using the final keyword, written in upper case using snake case.
Final
Keyword used to define a constant whose value cannot be changed.