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 does the extern keyword indicate?

  1. That a variable is defined locally.

  2. That a variable is only used within the file it's declared in.

  3. That a variable's storage is created only once across all files.

  4. That a variable exists, even if not yet encountered in the current file.

The correct answer is: That a variable exists, even if not yet encountered in the current file.

The extern keyword indicates that a variable is defined externally, meaning it has been declared in a separate file and can be accessed by other files in the same program. This allows for the sharing of variables across multiple files, making it easier for different parts of a program to communicate with each other. The other options are incorrect because they do not accurately describe the purpose of the extern keyword. Option A is incorrect because variables defined locally are typically only accessible within the same scope. Option B is incorrect because it suggests that the variable is limited to the current file, when in fact it can be accessed by other files in the program. Option C is incorrect because it implies that the variable's storage is limited to a single file, when the extern keyword allows for shared storage across multiple files. Therefore, the correct answer is D.