Mastering C++: A Comprehensive Quiz Based on 'Thinking in C++'

Disable ads (and more) with a membership for a one time $2.99 payment

Test your C++ skills with our quiz based on Bruce Eckel's 'Thinking in C++'. Dive into object-oriented programming, advanced topics, and fundamentals. Perfect for learners and experts alike. Assess your knowledge and become a C++ master!

Each practice test/flash card set has 50 randomly selected questions from a bank of over 500. You'll get a new set of questions each time!

Practice this question and more.


Where is the static variable 's' stored?

  1. On the stack

  2. In the global scope

  3. In the program's static data area

  4. On the heap

The correct answer is: In the program's static data area

Static variables in programming are special variables that are allocated memory only once and retain their value throughout the entire program's execution. These variables are stored in the program's static data area in memory, which is a special region dedicated to storing global and static variables. Option A is incorrect because the stack is used for storing local variables and function calls, which are temporary and are removed once a function finishes executing. Option B is incorrect because global variables are also stored in the static data area. Option D is incorrect because the heap is used for dynamic memory allocation and is not specifically dedicated to storing the static variable 's'. Therefore, option C is the correct answer.