Please enable JavaScript to use CodeHS

Chapter 1

Primitive Types

1.3 Variables and Data Types

Variables and Types

Primitive Types

Numeric Type:

Char Type:

Boolean Type:

Reference Types

String Type

Final Keyword

Naming Variables

Variables

Using Final

Swapping Two Values

Check Your Understanding

  1. Incorrect Correct No Answer was selected Invalid Answer

Exercise: Answering Questions

Vocabulary

Term Definition
Variable A symbol or container that holds a value.
int `int` is a Java type that represents an integer (a whole number)
char `char` is a Java type that represents a single character (a single letter)
double `double` is a Java type that represents a real number with decimal values
Declare a variable Declaring a variable is defining it for the first time.
Initialize a variable Initializing a variable is giving it an initial value, or a starting value.
Primitive Type Primitive types are the basic, simple data types that are inherent to Java (int, double, char, and boolean)
Boolean A boolean is a true or false value.
Reference Type Reference variables store the address of the value
final Prevents variables from changing value.

Do you have feedback on this lesson? Let us know here
Rate this lesson:

Feedback on this lesson:

Issue found (optional):