21st November 2019


What is the use of static variable in C?

In the C programming language, static is used with global variables and functions to set their scope to the containing file. In local variables, static is used to store the variable in the statically allocated memory instead of the automatically allocated memory.

Similarly, it is asked, what is the meaning of static variable in Java?

A static variable is common to all the instances (or objects) of the class because it is a class level variable. Like variables we can have static block, static method and static class, to read about them refer: static keyword in java.

What is the use of a static variable?

static variables are used when only one copy of the variable is required. so if you declare variable inside the method there is no use of such variable it's become local to function only.. Variables declared static are commonly shared across all instances of a class.
Write Your Answer


80% people found this answer useful, click to cast your vote.

4 / 5 based on 1 vote.


Press Ctrl + D to add this site to your favorites!