answersLogoWhite

0


Best Answer

It contains data which left after previous usage of that area of the memory.

User Avatar

Wiki User

15y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Local variable if not initialized contains what?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What does a Java Boolean type variable declared but not yet initialized contain when its class is instanciated?

If it is a class or instance variable, it gets the default value of false. If it is a local variable (inside a method), it doesn't have a value until you explicitly set one.


What are storage classes in c?

There are four types of storage classes in c. It defines the scope and lifetime of a variable or function.1. auto - This is the default storage class inside a function. Auto can only be used with in functions. i.e. only for local variables, not for globals.2. register - The variables declared using the register storage class may stored in CPU registers instead of RAM. Since it doesn't have a memory location, the '&' operator for getting the address of the variable cannot be applied (in C). This storage class cannot be used for global scope data.3. static - In case of local variable, it is initialized at compile time and retains its value between the calls. By default the static variables will be initialized to zero, in case of pointer variable initialized to NULL.4. extern - Refers to a public variable defined somewhere else (often in a different source file.)


Why static variables are initialized to zero?

When a variable is declared, your computer assigns a section of memory to that variable. If the variable isn't initialized, there's no way of knowing what data is already stored in that section of memory, which can cause errors in your programs. In managed languages, such as C#, this is done automatically at declaration. Although it's still good practice to initialize variables yourself.


What happens if you don't initialize an instance variable of any of the primitive type in java?

Java by default initializes it to the default value for that primitive type. Thus an int will be initialized to 0(zero), a Boolean will be initialized to false.


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.

Related questions

What do you mean by initialization in c plus plus?

Not initialized variable: int myInt; Initialized variable: int myInt = 10;


Which variable is initialized once when program is compiled?

global and static


What does a Java Boolean type variable declared but not yet initialized contain when its class is instanciated?

If it is a class or instance variable, it gets the default value of false. If it is a local variable (inside a method), it doesn't have a value until you explicitly set one.


How can a PHP static be initialized?

PHP static can only be initialized using a literal or constant. You can not use an expression. You can initialize it to an integer but you may not to another variable.


Can you use variables in case clauses in the switch statement?

YES - If the variable i a constant (final variable that is already initialized) NO - If the variable is not constant and is assigned at run time.


If a variable is not initialized the value of that variable is likely to be?

It's almost impossible to predict, but the value will be some data left by OS when it was previously used.


What are storage classes in c?

There are four types of storage classes in c. It defines the scope and lifetime of a variable or function.1. auto - This is the default storage class inside a function. Auto can only be used with in functions. i.e. only for local variables, not for globals.2. register - The variables declared using the register storage class may stored in CPU registers instead of RAM. Since it doesn't have a memory location, the '&' operator for getting the address of the variable cannot be applied (in C). This storage class cannot be used for global scope data.3. static - In case of local variable, it is initialized at compile time and retains its value between the calls. By default the static variables will be initialized to zero, in case of pointer variable initialized to NULL.4. extern - Refers to a public variable defined somewhere else (often in a different source file.)


What are the value and preference of global variable?

Global variables can have any value, in C they are aumaticatically initialized to zero.


Why static variables are initialized to zero?

When a variable is declared, your computer assigns a section of memory to that variable. If the variable isn't initialized, there's no way of knowing what data is already stored in that section of memory, which can cause errors in your programs. In managed languages, such as C#, this is done automatically at declaration. Although it's still good practice to initialize variables yourself.


What happens if you don't initialize an instance variable of any of the primitive type in java?

Java by default initializes it to the default value for that primitive type. Thus an int will be initialized to 0(zero), a Boolean will be initialized to false.


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.


How a variable is declared and initialized during declaration in c?

During declaration, the declaration goes like this: extern <type> <variable-name> or <type> <function-name> (<parameter list>);