Computer Science, asked by Krishana679, 10 months ago

Which variables have local scope?

Answers

Answered by Anonymous
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 Anonymous
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