answersLogoWhite

0

Where the static variables are stored?

Updated: 9/17/2019
User Avatar

Wiki User

15y ago

Best Answer

initialize static variables are stored in data segment

where uninitialized static variables are stored in BSS(block storing for Symbol) it also a part of data segment

exp

static int i=10;//stored in data segment

static int i;//stored in BSS (uninitialized data segment)

Thanks

NAvin

User Avatar

Wiki User

12y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Where the static variables are stored?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Can variables be changed?

A static variable is one which is not stored on the stack but in the memory of the program. Static variables can be changed.


Where static variables stored?

they are stored in the memory.they obviously can't be stored in stack Bcoz there value won't be retained between function call.


Where are store static variable in memory?

static variables are stored in a special area of the heap called the "permanent generation".


Are static variables serialized in java?

No, static variables are not serialized.


Where does global static local register variables free memory and C Program instructions get stored?

* These are all implementation defined. Access to `register' specified indentifiers should be as fast as possible, so the compiler may place the value in a machine register. However, the compiler is free to treat a `register' declaration as an `auto' declaration. * Where free memory is maintained is an OS specific concept. Instructions are generally stored in code segement. Local Variables are stored in Stack. Register variables are stored in Register. Global & static variables are stored in data segment. The memory created dynamically are stored in Heap And the C program instructions get stored in code segment.


What is the storage allocation and scope of global extern static local and register variables?

AnswerLocal Variables are stored in Stack. Register variables are stored in Register. Global variables are stored in data segment. The memory created dynamically are stored in Heap And the C program instructions get stored in code segment and the extern variables also stored in data segment. Nooo NoooStatic variable will be stored in .BSS segment... (Block Started By Symbol)


Can static variables be changed?

No, a static variable means that there is only one copy of that variable, and it is shared by all members of the class, or by all callers of a function.A variable that is read-only would be marked as const or final (depending on language).


Why static functions cannot use instant variables?

Static functions are tied to a class, not to a particular object. A static function can only access static variables because it has no knowledge of member variables.


It is perfectly legal to any instance variable inside of a static method?

No. You will get compilation errors. The complier will complain that you are trying to access non static variables from inside a static method. A static method can access only static variables.


How do you access the static variable and static methods of a class?

In java we access static variables and static methods without creating objects. i.e.,we can access directly by using classname we can also access static variables and static methods by using objects which are created by using class where the static variables and static methods are available


Where auto variables are stored?

Auto variables are stored on the stack alongside all other local variables.


Can non static methods can access static variables?

Yes, they can