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.


What happens to the value of a static local variable between function calls?

  1. It is reset.

  2. It retains its value.

  3. It is incremented automatically.

  4. It is randomized.

The correct answer is: It retains its value.

Static local variables are initialized only once, and their value is retained between function calls. Option A is incorrect because static local variables are not reset between function calls. Option C is incorrect because static local variables are not automatically incremented. Option D is incorrect because static local variables are not randomly assigned a value between calls.