Variable

A variable is a named location that holds a value.

Related concepts:  NameValueAssignment

Closest Wikipedia entry:  Variable (computer science)

Misconceptions about Variable
35 documented Misconceptions

Check Yourself
Misconception
AssignmentCopiesObject — Java
Assignment copies the object
Misconception
CallerFrameContainsCalleeFormal — Java
Stack frame of caller includes variables for callee's formal parameters
Misconception
ControlledLocalAccess — Java
One can control access to local variables using access modifiers
Misconception
ExpressionAssigns — Java
An expression that reads a variable also updates its value after the evaluation
Misconception
ForEachIteratesOverIndices — Java
An enhanced for loop iterates over the indices of an array or a collection
Misconception
ForEachVariableIsElement — Java
One can assign to the variable of an enhanced for statement to store a value in the corresponding array or collection element
Misconception
ForVariableScopeBeyondLoop — Java
The scope of variables declared in a for loop header extends beyond the loop
Misconception
LocalVariablesAutoInitialized — Java
Local variables are automatically initialized
Misconception
LoopBodyScopeImpliesLoopLifetime — Java
Lifetime of variables declared in a loop body extends across all loop iterations
Misconception
MultiReferenceVariable — Java
A reference variable can point to multiple objects
Misconception
MultiValueVariable — Java
A variable can contain more than one value
Misconception
MustInitializeFieldInConstructor — Java
Constructors must assign values to all fields
Misconception
NoAtomicExpression — Java
Expressions must consist of more than one piece
Misconception
NoCastIfSameSize — Java
If a variable is at least as big (bit-width) as a value, then no cast is needed to a assign the value to the variable
Misconception
NoLocalVariables — Java
There are no local variables
Misconception
ReferenceToVariable — Java
References can point to variables
Misconception
ThisAsField — Java
this is a special field in the object
Misconception
ThisAssignable — Java
One can assign to this
Misconception
ThisExistsInStaticMethod — Java
this is a local variable, also in static methods
Misconception
UndeclaredVariables — Java
Variables can be used even without being declared beforehand
Misconception
UntypedVariables — Java
Variable declarations don't need a type
Misconception
UseOfSelfTypeImpliesRecursiveType — Java
If a class has a method that has a local variable, parameter, or return value with the class as its type, the class is a recursive type
Misconception
VariablesHoldExpressions — Java
= stores an expression in a variable
Misconception
VariablesHoldObjects — Java
A variable of a reference type contains a whole object
Misconception
AssignmentCopiesObject — JavaScript
Assignment copies the object
Misconception
ConstDeclarationCanBeLeftUninitialized — JavaScript
Declarations of constants do not need to be immediately initialized
Misconception
NoAtomicExpression — JavaScript
Expressions must consist of more than one piece
Misconception
ThisAssignable — JavaScript
One can assign to this
Misconception
AssignmentCopiesObject — Python
Assignment copies the object
Misconception
NoAtomicExpression — Python
Expressions must consist of more than one piece
Misconception
SelfAssignable — Python
Reassigning self changes the object on which a method is called
Misconception
VariablesHoldExpressions — Python
= stores an expression: it stores a reference to the expression in a variable
Misconception
VariablesHoldObjects — Python
A variable contains a whole object
Misconception
ExpressionAssigns — Scratch
An expression that reads a variable also updates its value after the evaluation
Misconception
ResetStateEachProgramExecution — Scratch
Running a Scratch program first resets the state of the world and then executes the program