If only one memory location is to be reserved for a class variable, no matter…
2014
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
- A.
extern
- B.
static
- C.
volatile
- D.
const
Attempted by 212 students.
Show answer & explanation
Correct answer: B
A static variable is associated with the class itself rather than individual instances. This ensures that only one memory location is allocated for the variable, which is shared by all objects created from that class.