Quiz Entry - updated: 2026.07.30
If you declare a state variable but never assign it, what value does it hold?
Its zero value — Solidity has no "null/undefined"; every type initialises to a defined default (0 for numbers, false for bool, the zero address for address, "" for string).
uint256 favoriteNumber; // this is 0, not undefined
Solidity variables are never uninitialised in the way they might be in other languages. Declaring uint256 favoriteNumber; is identical to uint256 favoriteNumber = 0;. Defaults by type:
| Type | Zero value |
|---|---|
uint / int |
0 |
bool |
false |
address |
0x0000...0000 (the zero address) |
string |
"" (empty) |
This matters for mappings especially: every key of a mapping already "exists" holding the zero value, so a lookup on a never-set key returns 0 rather than an error.
Go deeper:
Solidity docs: types — each type's default (zero) value.