Class-and-object
November 12, 2023Engineering-Mathematics
November 12, 2023OOPS
Question 90 |
If only one memory location is to be reserved for a class variable, no matter how many objects are instantiated, then the variable should be declared as
extern | |
static | |
volatile | |
const |
Question 90 Explanation:
→ The static storage class instructs the compiler to keep a local variable in existence during the life-time of the program instead of creating and destroying it each time it comes into and goes out of scope. Therefore, making local variables static allows them to maintain their values between function calls.
→ The static modifier may also be applied to global variables. When this is done, it causes that variable’s scope to be restricted to the file in which it is declared.
→ In C programming, when static is used on a global variable, it causes only one copy of that member to be shared by all the objects of its class.
→ The static modifier may also be applied to global variables. When this is done, it causes that variable’s scope to be restricted to the file in which it is declared.
→ In C programming, when static is used on a global variable, it causes only one copy of that member to be shared by all the objects of its class.
Correct Answer: B
Question 90 Explanation:
→ The static storage class instructs the compiler to keep a local variable in existence during the life-time of the program instead of creating and destroying it each time it comes into and goes out of scope. Therefore, making local variables static allows them to maintain their values between function calls.
→ The static modifier may also be applied to global variables. When this is done, it causes that variable’s scope to be restricted to the file in which it is declared.
→ In C programming, when static is used on a global variable, it causes only one copy of that member to be shared by all the objects of its class.
→ The static modifier may also be applied to global variables. When this is done, it causes that variable’s scope to be restricted to the file in which it is declared.
→ In C programming, when static is used on a global variable, it causes only one copy of that member to be shared by all the objects of its class.