Data Types and Variables in Java

0.0(0)
studied byStudied by 1 person
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/14

flashcard set

Earn XP

Description and Tags

Flashcards covering data types, variables, type casting, type conversion, and constants in Java programming.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

15 Terms

1
New cards

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.

2
New cards

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.

3
New cards

Byte

An 8-bit signed two’s complement integer that stores whole numbers from -128 to 127 and is helpful for saving memory.

4
New cards

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.

5
New cards

Int

A data type that stores whole numbers from -2147483648 to 2147483647 and is generally preferred for numeric values.

6
New cards

Long

A 64-bit two’s complement integer with a value range from -2^63 to 2^63-1.

7
New cards

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.

8
New cards

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.

9
New cards

Char

Data types that are strings of characters; upper and lower case alphabetic characters are accepted literally.

10
New cards

Boolean

A data type with one of two possible values (true and false) to represent the two truth values of logic and Boolean algebra.

11
New cards

Variables

Containers for storing data values of different types, such as String, int, float, char, and boolean.

12
New cards

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.

13
New cards

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.

14
New cards

Constant

A variable whose value cannot be changed, defined using the final keyword, written in upper case using snake case.

15
New cards

Final

Keyword used to define a constant whose value cannot be changed.