Which variables have local scope?
Answers
Answered by
39
Answer:
Scope of local variables. The scope of a variable is the region of a program in which the variable is visible, i.e., in which it is accessible by its name and can be used. In Java, the scope of a local variable is the body of the method in which it is declared.
Answered by
0
The variables that have local scope are the local variables.
- Local variables have limited scope which means that it exists only within the block of function that it is declared in.
- This can be explained with the help of example below:
var x = 2
function func ( )
{
var y = 3 ;
}
- In this code, the variable y has local scope as it can be only accessed within the block of function func( ).
Similar questions
Science,
5 months ago
Computer Science,
10 months ago
Computer Science,
10 months ago
Math,
1 year ago
English,
1 year ago