Interactive Computer Science Tutoring

Learn programming concepts interactively

AHA Schools Logo

Interactive Variables

An interactive way to learn about Java variables, scope, and naming

What are Variables? 🎯
📦

Variables are named containers for storing data values. In Java, they have a specific type, name, and scope!

Your Progress 🏆
Score0
Streak0 🔥
Completed: 0/10 challenges
Interactive Variable Playground
Click a variable to operate on it, or declare a new one.
💼
Instance VariablesEach object has its own copy
int cadence
0
double speed
0
int gear
1
boolean isBraking
false
🏢
Static VariablesShared across all objects
String brand
GeminiCycle
int wheelCount
2
⚙️
Local VariablesTemporary, method-scoped

No local variables declared yet.

Create one to see it here!

🎮
✨ Declare a Variable
🧩 Naming Convention Challenge
🏆
EASY10 pts
Challenge 1 of 10

Is this variable name valid and conventional in Java?

_myVariable
🏠 Variable Playground Controls
4 Instance
2 Static
0 Local
🎨 Experiment with different variable types and scopes to see how Java handles them!
Live Java Class
Your variable manipulations reflected in code
public class Bicycle {
// === INSTANCE VARIABLES ===
// Each Bicycle object gets its own copy of these.
int cadence = 0;
double speed = 0;
int gear = 1;
boolean isBraking = false;
// === STATIC (CLASS) VARIABLES ===
// Shared across all Bicycle objects. One copy for the whole class.
static String brand = "GeminiCycle";
static int wheelCount = 2;
public void someMethod() {
// === LOCAL VARIABLES ===
// Temporary state, only exists within this method's execution.
System.out.println("Method executed with current variable states.");
}
// Naming Convention Example
public void namingConventionExample() {
// A good variable name is descriptive and follows camelCase.
int numberOfGears = 6;
// Avoid single-letter names unless for temporary loops (i, j, k).
int x = 10; // What does 'x' represent?
// Constants are usually in all caps with underscores.
final int MAX_SPEED = 30;
}
}
Action History0/5
Log of your recent activities

No operations yet

Start by adding or modifying elements