Question

why might one use a static local variable? discuss why mentioning as well the disadvantage of...

why might one use a static local variable? discuss why mentioning as well the disadvantage of using the static variable
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Static Variable:Static Variable consists of a property of preserving the value even after they went out of their scope.It willn't be initialized again in the new scope.

Static variables are initialized with zero(0) by default.

Why use Static local variable?

Static local variables are GLOBAL VARIABLES.

Static local variable intialize only once inspite of how many times the function in which the variable is present called.

These variables doesn't required run-time overhead for allocation and de-allocation.

Direct access of these variables are more efficient.

This variable will create at statring of the program and destroys at the end of the program like gloabl variables.

These variables are used in cases like counting the no. of executions of a function.

Disadvantages of Static local Variable:

Static local Variables doesn't support Recursion.

Their storage can't be supported with other inactive sub-programs.

Static local variables aren't allowed in java.

Add a comment
Know the answer?
Add Answer to:
why might one use a static local variable? discuss why mentioning as well the disadvantage of...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT