Scope of variable is nothing but the statements or expressions in which the variable can be used. Any variable is in scope ( valid ) in the statements below its declaration. It will not be in scope or it will be invalid above its declaration.
Scope in same block CODE class ScopeInSameBlock OUTPUT x = 15 DESCRIPTION Any variable will be valid in the statements below its declaration. It will not be valid before it is declared. Here THINGS TO TRY
2-min video about scope of variables 3-min video for quiz in variables
|