answersLogoWhite

0

In the block that contains its definition.

/* i isn't useable here */

{ int i; /* i is useable here */ }

/* i isn't useable here */

User Avatar

Wiki User

13y ago

What else can I help you with?

Continue Learning about Engineering

What is a local variable and What statements are able to access a local variable?

A local variable is a variable that can only be called on by the module. Where as a global variable can be called upon by any module. Only statements made inside the same module can call on a local variable.


Is a global variable a non-local variable?

True, a variable cannot be both global and local. But if a global and a local variable share the same name, the local one will hide the global.


How can you declare global and local variable in pseudocode?

A local variable is a variable declared inside a construct, such as a class or function, while a global variable is a variable declared outside of any construct.


When a local variable has the same name as a field the local variable's name does this to the field's name?

When a local variable has the same name as a field, it shadows the field's name within its scope. This means that within that scope, any reference to the variable name will refer to the local variable rather than the field. As a result, the field becomes inaccessible directly by that name until the scope of the local variable ends. This can lead to confusion and potential bugs if not managed properly.


What is Variable Shadowing in Java?

In Java, there are three kinds of variables: local variables, instance variables, and class variables. Variables have their scopes. Different kinds of variables have different scopes. A variable is shadowed if there is another variable with the same name that is closer in scope. In other words, referring to the variable by name will use the one closest in scope, the one in the outer scope is shadowed.A Local Variable Shadows An Instance VariableInside a class method, when a local variable have the same name as one of the instance variable, the local variable shadows the instance variable inside the method block.

Related Questions

Which register is used as a local variable?

accumulator


What is a local variable and What statements are able to access a local variable?

A local variable is a variable that can only be called on by the module. Where as a global variable can be called upon by any module. Only statements made inside the same module can call on a local variable.


Is a global variable a non-local variable?

True, a variable cannot be both global and local. But if a global and a local variable share the same name, the local one will hide the global.


local?

local variable


What is volatile and why are using in java?

volatile variable is mainly used in multithreading environment. so let me explain it from that context.In a multithreading environment,for a variable which is not marked as volatile will be stored in local cache memory for each thread. Meaning each thread will have a local copy of the variable and they dont know about what value this variable is having in another thread. If a variable is marked volatile, then the updations to this variable will happen in the main memory and not in local cache


What is the difference between a static variable a global variable and a local variable?

A static variable is a variable allocated in static storage. A local variable is a variable declared inside a function. A global variable is a variable declared outside of any class or function. Note that local variables and global variables can both be allocated in static storage.


How you can declare local variable?

variable exit within a function and curly braces is local variable int main() { int x; }


What is local variable?

they are variable that has a lifetime within that block


How are the automatic variable also known as?

local variable


How can you declare global and local variable in pseudocode?

A local variable is a variable declared inside a construct, such as a class or function, while a global variable is a variable declared outside of any construct.


When a local variable has the same name as a field the local variable's name does this to the field's name?

When a local variable has the same name as a field, it shadows the field's name within its scope. This means that within that scope, any reference to the variable name will refer to the local variable rather than the field. As a result, the field becomes inaccessible directly by that name until the scope of the local variable ends. This can lead to confusion and potential bugs if not managed properly.


What happens to the value of a local variable when the module in which the variable is declared completes execution and control is passed to a different module?

The local variable goes away and the value is lost.