A variables scope is the region of a program within the variable Can be referred by its simple name.
Scope also determines when the system creates and destroys memory for the variables.
The location of the variables declaration within your program establish its scope and places it into one of these our categories.
if you are not assigning value then java runtime assigns default value to variable and when you try to access the variable you get the default value of the variable.
Data Types | Default value |
Boolean | False |
char | \u0000 |
int | 0/ 0l |
float | 0.0f / 0.0d |
any reference type | null |
Ask Question